Skip to content

Commit de8d216

Browse files
committed
Refactor: Replaced error.errors with .reason
This is more standard and will be printed in the console
1 parent eda23dd commit de8d216

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nsapi.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,25 @@ module.exports = class NSAPI {
6161

6262
// Normal API error
6363
if ( data.code && data.message ) {
64-
error = new Error( data.message );
64+
error = new Error( `API: ${data.message}` );
6565
error.code = data.code;
66-
error.errors = data.errors;
66+
error.reason = data.errors;
6767
throw error;
6868
}
6969

7070
// API field error - hard to replicate
7171
/* istanbul ignore next */
7272
if ( data.fieldErrors && data.fieldErrors.length ) {
7373
error = new Error( 'API field error' );
74-
error.errors = data.fieldErrors;
74+
error.reason = data.fieldErrors;
7575
throw error;
7676
}
7777

7878
// API error without message - hard to replicate
7979
/* istanbul ignore next */
8080
if ( data.errors && data.errors[0] ) {
8181
error = new Error( 'API error' );
82-
error.errors = data.errors;
82+
error.reason = data.errors;
8383
throw error;
8484
}
8585

0 commit comments

Comments
 (0)