Closed devpulse01 closed 10 months ago
Hi @devpulse01.
The component has been intentionally set up to never throw errors in order to make it safe to use and to prevent users from having to use error boundaries. However if you would like to monitor errors, I can add a new event that would be emitted when there is an error. Could you elaborate on what kind of errors are you interested in? Is it service errors?
In regards to logging, what kind of things would you like to log?
Hey Ovidijus,
Thank you for your reply.
Errors: If you can add a new event that is emitted in case of errors, that would be perfect. Yes, it's for service errors (e.g., wrong API key, wrong service parameters, etc.).
Logging: I think both are related. I would love to handle errors on my own and thus be able to log them within my users' context.
I'll implement a new event and update this thread when it is available to be used.
The new event is available on deep-chat-dev
and deep-chat-react-dev
packages version 9.0.91
.
Function: onError
Type: (error: string) => void
Example usage: deepChatRef.onError = (error) => {console.log(error);}
Event name: error
With the most straightforward implementation I could only return the error message that would be shown in the chat bubble. This can be coupled with the errorMessages
property to return the desired error.
Let me know if this works and is sufficient for you. Thanks!
Hi, this is now available in package version 1.4.5
.
See the onError
documentation for more information.
Hey Ovidijus,
Hope you're doing well. As I continue integrating deep-chat into my app, I've come across a couple of challenges related to error handling and logging.
Custom error handling: I'm on the lookout for a method to catch and manage errors that might pop up with the public deep-chat methods. The current setup doesn't seem to offer a way for custom error handling. It would be awesome if the methods could throw errors that I can then catch and handle in my own code.
Custom logging: On another note, I have a custom logger in my application. I'm interested in integrating this with the deep-chat methods. Is there a way to replace the default logging with my own logger?
Thank you! Best