Errors triggered by nano are extended with additional fields, this commits adds the typescript definition for them.
The name "RequestError" was chosen because it seems like it all nano errors are triggered by a request (a 'socket' or a 'couch' error).
I considered "NanoError", but the full type nano.NanoError doesn't sound better than nano.RequestError and no other interface have been prefixed with "Nano".
I've extracted the error fields from nano.js.
Testing recommendations
There's no typescript tests so far, I included this change in my typescript project.
This change can affect users if they uses nano with callbacks incorrectly, their project could fail building.
Errors are simple to fix. For example, on my project there was an instance where I used error.status instead of error.statusCode. Another issue is that I passed a callback that expected Error | undefined for the error field while nano sends Error | null.
Overview
Errors triggered by nano are extended with additional fields, this commits adds the typescript definition for them.
The name "RequestError" was chosen because it seems like it all nano errors are triggered by a request (a 'socket' or a 'couch' error).
I considered "NanoError", but the full type
nano.NanoError
doesn't sound better thannano.RequestError
and no other interface have been prefixed with "Nano".I've extracted the error fields from
nano.js
.Testing recommendations
There's no typescript tests so far, I included this change in my typescript project.
This change can affect users if they uses nano with callbacks incorrectly, their project could fail building.
Errors are simple to fix. For example, on my project there was an instance where I used
error.status
instead oferror.statusCode
. Another issue is that I passed a callback that expectedError | undefined
for the error field while nano sendsError | null
.Checklist