Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TalkerObserver onException/onError/onLog provide dynamic object for additional information passed through by handle method #74

Open
Hollow-Ego opened this issue Oct 17, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Hollow-Ego
Copy link

Is your feature request related to a problem? Please describe.
Just getting Error Details (exception, reason, stack) limits the ability to provide more context information. You can run into situations where just having these isn't enough to identify the cause and you want to send additional information like local variables or the arguments that were passed in to the crashing function. In my case I want to attach custom properties to a Crashlytics report.

Describe the solution you'd like
You should be able to set an optional dynamic object to the handle method, that then can be accessed in a talker observer.
Example of calling .handle:

final item = getItemById(id);
try {
// Something might throw when using the amount
}
catch(e,st){
final context = {"itemAmount": item.amount};
talker.handle(e,st, "Couldn't modify item amount", context);
}

Example of a TalkerObserver using the context

 Function(TalkerException e) get onException => (e) {
       final report =   FirebaseCrashlytics.instance;
       e.context.ForEach((key,value) => {
              report.setCustomKey(key,value);
       });
       report.recordError(e.exception, stack: e.stackTrace, reason: e.message);
      };

Describe alternatives you've considered
Alternatively you could write your own error handler, but you would lose all the benefits of this package.

Additional context
The idea with additional context information is based on structured logging in the .net world.

@Frezyx Frezyx added the enhancement New feature or request label Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants