-
Notifications
You must be signed in to change notification settings - Fork 3
Error handling
SaltwaterC edited this page Mar 14, 2013
·
4 revisions
- You may use the client in development mode in order to see the debug messages. Just define the NODE_ENV environment variable with the value 'development'.
- If there's a FTP error, then the returned error argument also contains the FTP status code of the failed request (error.code). All 4xx and 5xx codes are considered to be errors. The client does not retry even though 4xx may be considered temporary errors. The only exception to this rule is the 500 error for the SIZE command where the library does not handle it as error due to potential lack of FTP extensions into the server as defined by RFC 3659.
Each failure has an attached error code. The write stream, if the file is saved to the disk, returns the file path into the error.file property. The rest of the failures, return the URL of the request, as error.url. Note that the error.url property contains the parsed URL information.
Besides the actual FTP error codes, the error codes are:
- 1 - write stream failure
- 2 - NOT IMPLEMENTED in v0.3
- 3 - data socket error
- 4 - data socket timeout
- 5 - command socket failure
- 6 - NOT IMPLEMENTED in v0.3
- 7 - command socket timeout
- 8 - SIZE command not implemented per RFC 3659
- 9 - could not get the data socket information
- 10 - wrong file size at succesful transfer
- 11 - command socket prematurely closed
- 12 - the file does not exist at the end of the transfer
- 13 - buffer too large (SlowBuffer is limited to 0x3FFFFFFF bytes aka 1073741823)
The errors involving the FTP itself are passed back to the completion callback as the error argument. Non-recoverable errors (eg: coding errors on your end) throw exceptions. For the moment, the errors are thrown for these cases:
- the Options object is not an Object
- the url option is missing
- the bufferType option is not 'string' or 'buffer'