Skip to content

Instantly share code, notes, and snippets.

@hpoul
Last active April 11, 2022 16:09
Show Gist options
  • Save hpoul/8fef76c5ba1c76a23042025097ed3e0a to your computer and use it in GitHub Desktop.
Save hpoul/8fef76c5ba1c76a23042025097ed3e0a to your computer and use it in GitHub Desktop.
class FirstError { }
class SecondError { }
Future<void> someApi() {
return Future(() {
throw FirstError();
}).catchError((error, stackTrace) {
print("inner: $error");
// although `throw SecondError()` has the same effect.
return Future.error(SecondError());
});
}
void main() {
someApi()
.then((val) { print("success"); })
.catchError((error, stackTrace) { print("outer: $error"); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment