How to pass the exception caught in inner catch to outer catch in a nested try catch
By : user3221865
Date : March 29 2020, 07:55 AM
help you fix your problem After error_log(); in the first try-catch, type throw $e; (on a new line). This will throw the error again, and the outer try-catch will handle it.
|
Why cannot I catch the exception thrown in nested catch clause using 'outer' catch?
By : Jakey1200
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , But why cant we catch the exception thrown in a nested catch clause using an outer catch? code :
static void exceptions(boolean b) {
try {
try {
if (b) throw new FileNotFoundException("FIRST");
try {
throw new IOException("SECOND");
} catch (FileNotFoundException e) {
System.out.println("This will never been printed out.");
}
} catch (FileNotFoundException e) {
System.out.println(e + " is handled by exceptions().");
try {
throw new FileNotFoundException("THIRD");
} catch (FileNotFoundException fe) {
System.out.println(fe + " is handled by exceptions() - nested.");
}
// will be caught by the nested try/catch at the end.
throw new IOException("FOURTH");
}
} catch (Exception e) {
System.out.println(e + " is handled by exceptions().");
}
}
|
RXJS Catch operator not catch the Error
By : user7316747
Date : March 29 2020, 07:55 AM
I hope this helps . The problem is that the error in the login method is thrown outside of the observable chain composed in your effect. code :
import 'rxjs/add/observable/throw';
login(email: string, password: string): Observable<any> {
if (email == 'a@gmail.com') {
return Observable.of('Login Success');
}
return Observable.throw(new Error('Username or password incorrect'));
}
|
RxJS catchError operator does not catch an error on an observable created from a Promise
By : user3434492
Date : March 29 2020, 07:55 AM
will help you Maybe fix your promise code first will solve your problem there is no need to catch, let the error flow through code :
private createDirectory(dirName) {
return defer(()=>this.file.createDir(path, dirName))
}
|
Intercepting Observable.throw using .catch while doing async operations inside the .catch
By : Patrick Igwe
Date : March 29 2020, 07:55 AM
This might help you If you just want to transform the error to another object you can't do it inside subscribe because you want the new error to be passed down the chain. Instead inside catch run this.errorHandler.transform and turn its result into an error notification: code :
return this.http.post<Shorty>(url, shorty)
.catch(err => this.errorHandler.transform(err) // I'm assuming this returns an Observable
.map(newError => {
throw newError; // Rethrow the error so it'll be passed down as an `error` notification.
})
);
|