@@ -3,24 +3,26 @@ import ExtendableError from 'extendable-error';
33
44const isString = d => Object . prototype . toString . call ( d ) === '[object String]' ;
55const isObject = d => Object . prototype . toString . call ( d ) === '[object Object]' ;
6+ interface ErrorConfig {
7+ message : string ;
8+ time_thrown : any ;
9+ data : any ,
10+ options : any ,
11+ }
12+
613class ApolloError extends ExtendableError {
7- name : any ;
8- message : any ;
14+ name : string ;
15+ message : string ;
916 time_thrown : any ;
1017 data : any ;
1118 path : any ;
1219 locations : any ;
1320 _showLocations : any ;
14- constructor ( name , {
15- message,
16- time_thrown = ( new Date ( ) ) . toISOString ( ) ,
17- data = { } ,
18- options = { } ,
19- } ) {
20- const t = ( arguments [ 2 ] && arguments [ 2 ] . time_thrown ) || time_thrown ;
21- const d = ( ( arguments [ 2 ] && arguments [ 2 ] . data ) || { } )
22- const m = ( arguments [ 2 ] && arguments [ 2 ] . message ) || message ;
23- const opts = ( ( arguments [ 2 ] && arguments [ 2 ] . options ) || { } )
21+ constructor ( name , config : ErrorConfig ) {
22+ const t = ( config && config . time_thrown ) || ( new Date ( ) ) . toISOString ( ) ;
23+ const d = ( config && config . data || { } )
24+ const m = ( config && config . message ) || '' ;
25+ const opts = ( ( config && config . options ) || { } )
2426
2527 super ( m ) ;
2628
@@ -53,7 +55,8 @@ class ApolloError extends ExtendableError {
5355
5456export const isInstance = e => e instanceof ApolloError ;
5557
56- export const createError = ( name , config ) => {
58+ export const createError = ( name , config : ErrorConfig ) => {
59+ console . log ( 'config' , config ) ;
5760 assert ( isObject ( config ) , 'createError requires a config object as the second parameter' ) ;
5861 assert ( isString ( config . message ) , 'createError requires a "message" property on the config object passed as the second parameter' ) ;
5962 const e = ApolloError . bind ( null , name , config ) ;
0 commit comments