While error handling in Neoroute is generally simple, this page gives you a more in-depth look into what kinds of errors you can get and where they are handled.
Errors from anywhere in Neoroute are generally handled in one central place: In the Router object where you specified the ErrorHandler.
That ErrorHandler converts any error that happens to a string message that can be sent to the user.
ErrorHandler. The message will be sent along with the response to the client.neoroute.NewError) are passed to the function to get the text for the error message.The default ErrorHandler always returns "Something went wrong" and logs the error to the console using Neoroute’s default logger. Learn how to change it below.
Neoroute sometimes also logs things into your console. For this, we use slog.Logger from the standard library as it is pretty extensible and basically a standard.
You can set the logger Neoroute uses like this:
neoroute.SetLogger(/* your logger */)
You can use this to format Neoroute’s logs a little colorful or make them appear in JSON.