@@ -42,7 +42,7 @@ class Request {
42
42
return oauth . authorize ( req ) ;
43
43
}
44
44
45
- error ( message , response , body , error ) {
45
+ error ( message , response , error ) {
46
46
if ( ! error ) error = new Error ( message ) ;
47
47
error . response = {
48
48
statusCode : response . statusCode
@@ -98,10 +98,20 @@ class Request {
98
98
return ;
99
99
}
100
100
101
+ if ( response === - 1 || body === - 1 ) {
102
+ const msg = 'A meaningless error has occurred, returning -1. ' +
103
+ 'This could be the result of an incorrect folder setup.' ;
104
+ const error = this . error ( msg , response ) ;
105
+ logger . error ( msg ) ;
106
+ reject ( error ) ;
107
+ cb ( error , body , response ) ;
108
+ return ;
109
+ }
110
+
101
111
// Handle error codes between 400 & 600
102
112
if ( response . statusCode >= 400 && response . statusCode < 600 ) {
103
113
const msg = `Request failed with code: ${ response . statusCode } ` ;
104
- const error = this . error ( msg , response , body ) ;
114
+ const error = this . error ( msg , response ) ;
105
115
106
116
logger . error ( msg ) ;
107
117
reject ( error ) ;
@@ -127,7 +137,7 @@ class Request {
127
137
128
138
if ( json . hasOwnProperty ( 'error' ) || json . hasOwnProperty ( 'errors' ) ) {
129
139
const errorMessage = json . error || JSON . stringify ( json . errors ) ;
130
- const serverError = this . error ( errorMessage , response , body ) ;
140
+ const serverError = this . error ( errorMessage , response ) ;
131
141
cb ( serverError , body , response ) ;
132
142
reject ( serverError ) ;
133
143
return ;
@@ -140,7 +150,7 @@ class Request {
140
150
} catch ( e ) {
141
151
142
152
const malformedMsg = `Error parsing response body: ${ e . message || e } ` ;
143
- const malformedError = this . error ( malformedMsg , body , response , e ) ;
153
+ const malformedError = this . error ( malformedMsg , response , e ) ;
144
154
145
155
logger . error ( malformedMsg ) ;
146
156
cb ( malformedError , body , response ) ;
0 commit comments