Questions tagged [rethrow]

use for issues on rethrowing catch exception

In terms of exception handling, this refers to throwing the exception again.

73 questions
1
vote
1 answer

PHP: Throw exception with multiple original/previous exceptions?

Consider the following code, where I want to throw a new exception to wrap "previous" exceptions that I just caught. try { doSomething(); } catch (SomethingException $eSomething) { try { rollback(); } catch (RollbackException $eRollback)…
donquixote
  • 4,877
  • 3
  • 31
  • 54
1
vote
2 answers

rethrowing exception handled in preceding catch block

on oracle ofiicial site write (http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html#rethrow) In detail, in Java SE 7 and later, when you declare one or more exception types in a catch clause, and rethrow the…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
1
vote
2 answers

exception creating 2D Array: clean-up before re-throw in C++

I want to have a function which dynamically creates and returns a 2D array or when memory allocation fails passes the exception without information loss after cleaning up already allocated rows: double **create (int rows, int cols) { double…
mb84
  • 683
  • 1
  • 4
  • 13
1
vote
4 answers

Try catch and re-throw exception

I saw some code the other day in one of our projects that uses a try catch and re-throws the caught exception like this: try { exceptionProneCode(); } catch(Exception ex) { throw ex; } Nothing else was done with the exception in the catch…
Cameron Tinker
  • 9,634
  • 10
  • 46
  • 85
1
vote
2 answers

Rethrow an exception in a try block c#

My first question here and I am not that great at english so please bear with me, I am writing an application that allows users to write scripts that interface with 'drivers', the scripts and drivers are all separate class library dll's. These…
Jeffnl
  • 261
  • 1
  • 4
  • 21
1
vote
1 answer

Rethrow different caught exceptions in java

I have the following dowload function. I catch some possible exceptions on the way, and store them in an Exception type variable, and after cleaning up in the finally block, I would like to re-throw the original exception (if there was one caught)…
Gavriel
  • 18,880
  • 12
  • 68
  • 105
1
vote
1 answer

ReThrowing exception and handling it with in a loop ...?

I experimented a lot with re throwing exceptions and came on to following conclusions: 1)We might want to re throw if we want to give more details about exception like (Inner exception) 2)we may re throw to entirely terminate the program .. 3)if we…
Sana.91
  • 1,999
  • 4
  • 33
  • 52
0
votes
3 answers

In Java, if a general exception is caught and rethrown, will outer methods still be able to catch specific exceptions?

In Java, if a general exception is caught and rethrown, will outer methods still be able to catch specific exceptions? In other words, can I do this: try { try { //... } catch (Exception e) { //... throw e; } }…
Anonymous
  • 3,334
  • 3
  • 35
  • 50
0
votes
0 answers

Java 8, Optional. throwing Exceptions, and Re-throwing exceptions, preventing null

I have confusing (lack of comprehension) trying to translate some part of my code to Optional on Java 8. First example mock Code private void privateMethodOne(CustomRequesDto customRequesDto) { // Some lines of code …
joseluisbz
  • 1,491
  • 1
  • 36
  • 58
0
votes
1 answer

How to catch a base class constructor's exception in C++?

I have a class that is derived from another class. I want to be able to catch and re-throw the exception(s) thrown by the derived class's constructor in my derived class's constructor. There seems to be a solution for this in…
fakl
  • 127
  • 7
0
votes
5 answers

Flutter Image Asset cannot be shown ( image in class model )

I've made class model of places, and I want to show the logo of each place, I add the image location folder in class named place_model.dart and this is the code for place_model.dart : class Place{ final String imageUrl; final String mall; …
0
votes
3 answers

Catching an error that I dont want to catch

Everytime I run this code, everything works fine, but if deposit methods throws an error, only the catch in the main method catches the exception and prints the string, despite the catch in the ExceptionsDemo. Why does that happen? public class…
0
votes
0 answers

Why if we return from finally, rethrow from catch not works?

Why first case prints : "second level catch" "top level catch" and second case prints: only "second level catch"? Difference in finally block. Future main() async { try { secondLevelTryCatch(); } catch (e, s) { print("top level…
Андрей
  • 166
  • 2
  • 7
0
votes
0 answers

Try catch block doesn't catch rethrown error

UI code: try { authService.signInWithEmailAndPassword( emailController.text, passwordController.text); } catch (error) { print("ui rethrow"); } Auth service code: Future signInWithEmailAndPassword( String email, …
0
votes
1 answer

Rethrowing exceptions at place of function/object construction

In the case of functions, when exceptions may only throw at their place of execution (based on my lack of knowledge this is uncertain for me at the moment), sometimes the culprit may rely on the way the lambda was created, an example may be: //…
Delark
  • 1,141
  • 2
  • 9
  • 15