@@ -33,14 +33,17 @@ export class ApolloError extends ExtendableError {
3333 _showLocations : boolean = false ;
3434 _showPath : boolean = false ;
3535
36- constructor ( name : string , config : ErrorConfig ) {
37- super ( ( arguments [ 2 ] && arguments [ 2 ] . message ) || '' ) ;
38-
39- const t = ( arguments [ 2 ] && arguments [ 2 ] . time_thrown ) || ( new Date ( ) ) . toISOString ( ) ;
40- const m = ( arguments [ 2 ] && arguments [ 2 ] . message ) || '' ;
41- const configData = ( arguments [ 2 ] && arguments [ 2 ] . data ) || { } ;
36+ // NOTE: The object passed to the Constructor is actually `ctorData`.
37+ // We are binding the constructor to the name and config object
38+ // for the first two parameters inside of `createError`
39+ constructor ( name : string , config : ErrorConfig , ctorData : any ) {
40+ super ( ( ctorData && ctorData . message ) || '' ) ;
41+
42+ const t = ( ctorData && ctorData . time_thrown ) || ( new Date ( ) ) . toISOString ( ) ;
43+ const m = ( ctorData && ctorData . message ) || '' ;
44+ const configData = ( ctorData && ctorData . data ) || { } ;
4245 const d = { ...this . data , ...configData } ;
43- const opts = ( ( arguments [ 2 ] && arguments [ 2 ] . options ) || { } ) ;
46+ const opts = ( ( ctorData && ctorData . options ) || { } ) ;
4447
4548
4649 this . name = name ;
@@ -80,6 +83,9 @@ export const isInstance = e => e instanceof ApolloError;
8083export const createError = ( name : string , config : ErrorConfig ) => {
8184 assert ( isObject ( config ) , 'createError requires a config object as the second parameter' ) ;
8285 assert ( isString ( config . message ) , 'createError requires a "message" property on the config object passed as the second parameter' ) ;
86+ // NOTE: The first two parameters give to the constructor will always be name and config
87+ // Parameters passed to the constructor when `new` is invoked will be passed as
88+ // subsequent parameters.
8389 return ApolloError . bind ( null , name , config ) ;
8490} ;
8591
0 commit comments