From 3cc1c3867514685000d66f63fd59696bb3aff800 Mon Sep 17 00:00:00 2001 From: "Andrew E. Rhyne" Date: Thu, 22 Feb 2018 17:48:16 -0800 Subject: [PATCH] less ambiguity around data type --- dist/index.d.ts | 6 +++--- dist/index.js.map | 2 +- src/index.ts | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 79117f7..6634488 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -2,7 +2,7 @@ import ExtendableError from 'extendable-error'; export interface ErrorConfig { message: string; time_thrown?: string; - data?: any; + data?: object; options?: { showPath?: boolean; showLocations?: boolean; @@ -12,7 +12,7 @@ export interface ErrorInfo { message: string; name: string; time_thrown: string; - data?: {}; + data?: object; path?: string; locations?: any; } @@ -20,7 +20,7 @@ export declare class ApolloError extends ExtendableError { name: string; message: string; time_thrown: string; - data: any; + data: object; path: any; locations: any; _showLocations: boolean; diff --git a/dist/index.js.map b/dist/index.js.map index d1908b6..923a414 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,+BAAiC;AACjC,qDAA+C;AAE/C,IAAM,QAAQ,GAAG,UAAA,CAAC,IAAI,OAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,EAAvD,CAAuD,CAAC;AAC9E,IAAM,QAAQ,GAAG,UAAA,CAAC,IAAI,OAAA,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,EAAvD,CAAuD,CAAC;AAqB9E;IAAiC,+BAAe;IAU9C,qBAAY,IAAY,EAAE,MAAmB;QAA7C,YACE,kBAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,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ACtC,CAAC;IAED,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QACd,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;AACnC,CAAC,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ba7b3c8..cb9d9d5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ const isObject = d => Object.prototype.toString.call(d) === '[object Object]'; export interface ErrorConfig { message: string; time_thrown?: string; - data?: any; + data?: object; options?: { showPath?: boolean; showLocations?: boolean; @@ -18,7 +18,7 @@ export interface ErrorInfo { message: string; name: string; time_thrown: string; - data?: {}; + data?: object; path?: string; locations?: any; } @@ -27,7 +27,7 @@ export class ApolloError extends ExtendableError { name: string; message: string; time_thrown: string; - data: any; + data: object; path: any; locations: any; _showLocations: boolean = false; @@ -39,8 +39,9 @@ export class ApolloError extends ExtendableError { const t = (arguments[2] && arguments[2].time_thrown) || (new Date()).toISOString(); const m = (arguments[2] && arguments[2].message) || ''; const configData = (arguments[2] && arguments[2].data) || {}; - const d = { ...this.data, ...configData } - const opts = ((arguments[2] && arguments[2].options) || {}) + const d = { ...this.data, ...configData }; + const opts = ((arguments[2] && arguments[2].options) || {}); + this.name = name; this.message = m;