Skip to content

refactor: stop losing the original stack trace from dart 2.16 #2995

Open
@PlugFox

Description

@PlugFox

You must stop losing the original source stack trace like this (just for example):

} on FirebaseAuthException catch (e) {
throw SignUpWithEmailAndPasswordFailure.fromCode(e.code);
} catch (_) {
throw const SignUpWithEmailAndPasswordFailure();
}

it's big trouble, to read exceptions without source stacktraces, especially in crashlytics or sentry like logs

from dart 2.16 you must use Error.throwWithStackTrace like this:

//@dart=2.16

...

} on FirebaseAuthException catch (e, stackTrace) {
  Error.throwWithStackTrace(
    SignUpWithEmailAndPasswordFailure.fromCode(e.code),
    stackTrace,
  );
}

also, instead:

} catch (_) {

you must write:

} on Object {

or:

} on Object catch (error, stackTrace) {

Metadata

Metadata

Assignees

Labels

exampleExample applicationgood first issueGood for newcomersrefactorRefactor an existing implementation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions