Currently, the router's onError function is only able to receive classes that extends Error and crashing when the init throws any class that extends Exception:
The following _TypeError was thrown running a test:
type '_Exception' is not a subtype of type 'Error'
When the exception was thrown, this was the stack:
#0 _NuRouterLoaderState._initModule (package:nuvigator/src/next/v1/nu_router.dart:399:33)
<asynchronous suspension>
...
Based on the approach used in bloc library, this PR changes the onError function to receive an Object as error, so we can receive both Errors and Exceptions. It's important to say that in dart we can throw any class.
Thanks! Do you mind bumping the package version in the pubspec.yaml and adding a changelog entry? I think this is an API breaking change, so maybe it's better to bump a major
Currently, the router's onError function is only able to receive classes that extends Error and crashing when the init throws any class that extends Exception:
nu_router.dart
example_router.dart
Output:
Based on the approach used in bloc library, this PR changes the onError function to receive an Object as error, so we can receive both Errors and Exceptions. It's important to say that in dart we can throw any class.