Skip to content

Commit 1ea7a07

Browse files
committed
repaired indentation
1 parent 431c15f commit 1ea7a07

File tree

2 files changed

+75
-71
lines changed

2 files changed

+75
-71
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# intellij idea
2+
.idea
3+
4+
15
# Logs
26
logs
37
*.log

src/index.ts

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,94 +5,94 @@ const isString = d => Object.prototype.toString.call(d) === '[object String]';
55
const isObject = d => Object.prototype.toString.call(d) === '[object Object]';
66

77
export interface ErrorConfig {
8-
message: string;
9-
time_thrown?: string;
10-
data?: any;
11-
options?: {
12-
showPath?: boolean;
13-
showLocations?: boolean;
14-
},
8+
message: string;
9+
time_thrown?: string;
10+
data?: any;
11+
options?: {
12+
showPath?: boolean;
13+
showLocations?: boolean;
14+
};
1515
}
1616

1717
export interface ErrorInfo {
18-
message: string;
19-
name: string;
20-
time_thrown: string;
21-
data: string;
22-
path: string;
23-
locations: string;
18+
message: string;
19+
name: string;
20+
time_thrown: string;
21+
data: string;
22+
path: string;
23+
locations: string;
2424
}
2525

2626
export class ApolloError extends ExtendableError {
27-
name: string;
28-
message: string;
29-
time_thrown: string;
30-
data: any;
31-
path: any;
32-
locations: any;
33-
_showLocations: boolean=false;
34-
35-
constructor (name:string, config: ErrorConfig) {
36-
super((arguments[2] && arguments[2].message) || '');
37-
38-
const t = (arguments[2] && arguments[2].time_thrown) || (new Date()).toISOString();
39-
const m = (arguments[2] && arguments[2].message) || '';
40-
const configData = (arguments[2] && arguments[2].data) || {};
41-
const d = {...this.data, ...configData}
42-
const opts = ((arguments[2] && arguments[2].options) || {})
43-
44-
this.name = name;
45-
this.message = m;
46-
this.time_thrown = t;
47-
this.data = d;
48-
this._showLocations = !!opts.showLocations;
49-
}
50-
51-
serialize (): ErrorInfo {
52-
const { name, message, time_thrown, data, _showLocations, path, locations } = this;
53-
54-
let error: ErrorInfo = {
55-
message,
56-
name,
57-
time_thrown,
58-
data,
59-
path,
60-
locations
61-
};
62-
63-
if (_showLocations) {
64-
error.locations = locations;
65-
error.path = path;
66-
}
67-
68-
return error;
69-
}
27+
name: string;
28+
message: string;
29+
time_thrown: string;
30+
data: any;
31+
path: any;
32+
locations: any;
33+
_showLocations: boolean = false;
34+
35+
constructor(name: string, config: ErrorConfig) {
36+
super((arguments[2] && arguments[2].message) || '');
37+
38+
const t = (arguments[2] && arguments[2].time_thrown) || (new Date()).toISOString();
39+
const m = (arguments[2] && arguments[2].message) || '';
40+
const configData = (arguments[2] && arguments[2].data) || {};
41+
const d = { ...this.data, ...configData }
42+
const opts = ((arguments[2] && arguments[2].options) || {})
43+
44+
this.name = name;
45+
this.message = m;
46+
this.time_thrown = t;
47+
this.data = d;
48+
this._showLocations = !!opts.showLocations;
49+
}
50+
51+
serialize(): ErrorInfo {
52+
const { name, message, time_thrown, data, _showLocations, path, locations } = this;
53+
54+
let error: ErrorInfo = {
55+
message,
56+
name,
57+
time_thrown,
58+
data,
59+
path,
60+
locations
61+
};
62+
63+
if (_showLocations) {
64+
error.locations = locations;
65+
error.path = path;
66+
}
67+
68+
return error;
69+
}
7070
}
7171

7272
export const isInstance = e => e instanceof ApolloError;
7373

74-
export const createError = (name:string, config: ErrorConfig) => {
75-
assert(isObject(config), 'createError requires a config object as the second parameter');
76-
assert(isString(config.message), 'createError requires a "message" property on the config object passed as the second parameter');
77-
return new ApolloError(name, config);
74+
export const createError = (name: string, config: ErrorConfig) => {
75+
assert(isObject(config), 'createError requires a config object as the second parameter');
76+
assert(isString(config.message), 'createError requires a "message" property on the config object passed as the second parameter');
77+
return new ApolloError(name, config);
7878
};
7979

8080
export const formatError = (error, returnNull = false): ErrorInfo => {
81-
const originalError = error ? error.originalError || error : null;
81+
const originalError = error ? error.originalError || error : null;
8282

83-
if (!originalError) return returnNull ? null : error;
83+
if (!originalError) return returnNull ? null : error;
8484

85-
const { name } = originalError;
85+
const { name } = originalError;
8686

87-
if (!name || !isInstance(originalError)) return returnNull ? null : error;
87+
if (!name || !isInstance(originalError)) return returnNull ? null : error;
8888

89-
const { time_thrown, message, data, _showLocations } = originalError;
89+
const { time_thrown, message, data, _showLocations } = originalError;
9090

91-
if (_showLocations) {
92-
const { locations, path } = error;
93-
originalError.locations = locations;
94-
originalError.path = path;
95-
}
91+
if (_showLocations) {
92+
const { locations, path } = error;
93+
originalError.locations = locations;
94+
originalError.path = path;
95+
}
9696

97-
return originalError.serialize();
97+
return originalError.serialize();
9898
};

0 commit comments

Comments
 (0)