@@ -3,24 +3,26 @@ import ExtendableError from 'extendable-error';
3
3
4
4
const isString = d => Object . prototype . toString . call ( d ) === '[object String]' ;
5
5
const 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
+
6
13
class ApolloError extends ExtendableError {
7
- name : any ;
8
- message : any ;
14
+ name : string ;
15
+ message : string ;
9
16
time_thrown : any ;
10
17
data : any ;
11
18
path : any ;
12
19
locations : any ;
13
20
_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 ) || { } )
24
26
25
27
super ( m ) ;
26
28
@@ -53,7 +55,8 @@ class ApolloError extends ExtendableError {
53
55
54
56
export const isInstance = e => e instanceof ApolloError ;
55
57
56
- export const createError = ( name , config ) => {
58
+ export const createError = ( name , config : ErrorConfig ) => {
59
+ console . log ( 'config' , config ) ;
57
60
assert ( isObject ( config ) , 'createError requires a config object as the second parameter' ) ;
58
61
assert ( isString ( config . message ) , 'createError requires a "message" property on the config object passed as the second parameter' ) ;
59
62
const e = ApolloError . bind ( null , name , config ) ;
0 commit comments