» Home » Throw » Page 1
Is it possible to throw a java exception through the calling method of a base class that does not throw exceptions?
Category : Java

This may be a ridiculous Java question about exception handling, but I have a UI actor (an Android Activity) that is requesting services from my subclass of ContentProvider. The subclass wants to throw some exceptions when sd-card is full, sd-card is missing, network i/o errros, etc. However, when I code the CP-subclass to throw my exceptions, the compiler offers to add the exceptions to the


View Replies


Node.js (with socket.io and express) throw “events.js:71 throw arguments[1]; // Unhandled 'error' event”
Category : Programming Languages

I running express (nginx proxy) with socket.io and after few moments (app for some time works fine) after server start console throw this:


events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: socket hang up
at createHangUpError (http.js:1360:15)
at ServerResponse.OutgoingMessage._writeRaw (http.js:507

View Replies


Do you throw an exception when you know the method you're calling would just throw the same thing?
Category : Programming Languages

Say I have a method like this*:


public T GetItem(int index)
{
if (index < 0 || index >= _privateList.Count)
{
throw new ArgumentOutOfRangeException("index");
}
return _privateList[index];
}

Would you include that throw or leave it out? On the one hand I feel like it's good to handle


View Replies


Is there an equivalent in T-SQL to C#'s “throw;” to re-throw exceptions?
Category : C & C++ & C#

The title really is the question for this one: Is there an equivalent in T-SQL to C#'s "throw;" to re-throw exceptions?


In C# one can do this:


try
{
DoSomethingThatMightThrowAnException();
}
catch (Exception ex)
{
// Do something with the exception
throw; // Re-throw it as-is.
}

Is there somethin


View Replies


javascript what is the difference in throw new Error and throw(object)
Category : Web Design

I want to write a common error handler which will catch custom errors thrown on purpose at any instance of the code.


When I did throw new Error('sample') like in the following code


<script>
try{
throw new Error({'hehe':'haha'})
//throw new Error('hehe');
}catch(e)
{
alert(e)
console.log(e);
}
<

View Replies


difference between throw and throw new Exception()
Category : Programming Languages

what is the difference between


try { ... }
catch{ throw }

and


try{ ... }
catch(Exception e) {throw new Exception(e.message) }

Regardless that the second shows a message ?


View Replies


How to throw an Exception when your method signature doesn't allow to throw Exception?
Category : Programming Languages

I have a method like this:


public void getSomething(){
...
}

I want to throw an exception inside getSomething. The compiler will not allow me to do that because my method doesn't allow Exception to be thrown in there. But I need to throw a subclass of Exception for my testing (I can't throw Unchecked exception). This is clearly a hack but I need it


View Replies


Can a custom stream throw its own custom exceptions or should it only throw IOException?
Category : Programming Languages

I have my own Connection class and a ConnectionStream class which essentially just wraps the Connection's send/receive methods.


The Connection send/receive methods can throw exceptions like ServerClosedConnException or NetworkShutdownException


Should my Stream be catching these and wrapping them in IOException (using innerException), or can it just let them bubble up to


View Replies


In C++, is there a difference between “throw” and “throw ex”?
Category : C & C++ & C#

I'd like to ask this question (also here), but this time about C++.


What is the difference in C++ between


try { /*some code here*/}
catch(MyException& ex)
{ throw ex;}

and


try { /*some code here*/}
catch(MyException& ex)
{ throw;}

Is it just in the stack trace (which in C++ is in an


View Replies


Catch vs Catch (Exception e) and Throw vs Throw e
Category : Programming Languages

Are these two code examples the same? Catch and Catch (Exception e) have the same output, and the result is also the same if I write Throw or Throw e.


Main:


try
{
A();
//B();
}
catch (Exception e)
{
Console.WriteLine("{0} exception caught.", e);
}

Code 1:


static void A()
{
View Replies


Next
2012 / 2017 Copyrights BigHow , All Rights Reserved .