Hi guys. Im curious how errors are handled in the ...
# community-help
l
Hi guys. Im curious how errors are handled in the nodejs package. I thought every call would throw errors, but it seems with documents().import it can return errors. So i just want to clarify, is import the only call that returns errors, and most all others throw errors?
f
The import function will throw if any of the document import operations aren't successful. We don't return any errors as values, every function throws an error depending on its response http code
l
interface ImportResponseSuccess { success: true; } export interface ImportResponseFail { success: false; error: string; document: DocumentSchema; code: number; } export type ImportResponse = ImportResponseSuccess | ImportResponseFail; https://github.com/typesense/typesense-js/blob/master/src/Typesense/Documents.ts#L391 for sure?
f
If you check their references you'll see that we throw if there are any failures. These are DTOs essentially.
l
okay yes i see. thank you
🙌 1
f
No prob!