Error handling
Gracefully handle Nabla SDK errors
API calls error handling
All methods on NablaClient
and NablaMessagingClient
can throw an exception.
AuthenticationError
is the type you might want to handle specifically: when a call to NablaClient.setCurrentUserOrThrow
is missing before calling an authenticated API or when the SessionTokenProvider
failed to get fresh tokens.
See all cases in the errors.ts file
Logging
Errors will also be logged so if you need more control on what's logged, you can do it during the SDK initialization:
const nablaClient = new NablaClient({
configuration: {
// ...
logger: {
debug: (message: string, error?: any) => {
// TODO: Handle debug log
},
info: (message: string, error?: any) => {
// TODO: Handle info log
},
warn: (message: string, error?: any) => {
// TODO: Handle warn log
},
error: (message: string, error?: any) => {
// TODO: Handle error log
},
},
},
});
Updated 6 months ago