apollo-server-errors
Advanced tools
Comparing version 2.3.1-alpha.0 to 2.3.1
@@ -152,2 +152,9 @@ "use strict"; | ||
const enrichedErrors = errors.map(error => enrichError(error, debug)); | ||
const makePrintable = error => { | ||
if (error instanceof Error) { | ||
const graphQLError = error; | ||
return Object.assign({ message: graphQLError.message }, (graphQLError.locations && { locations: graphQLError.locations }), (graphQLError.path && { path: graphQLError.path }), (graphQLError.extensions && { extensions: graphQLError.extensions })); | ||
} | ||
return error; | ||
}; | ||
if (!formatter) { | ||
@@ -158,3 +165,3 @@ return enrichedErrors; | ||
try { | ||
return formatter(error); | ||
return makePrintable(formatter(error)); | ||
} | ||
@@ -161,0 +168,0 @@ catch (err) { |
{ | ||
"name": "apollo-server-errors", | ||
"version": "2.3.1-alpha.0", | ||
"version": "2.3.1", | ||
"author": "opensource@apollographql.com", | ||
@@ -22,3 +22,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "ec185a874c2f07b3724db62a3ec8560cfe3850af" | ||
"gitHead": "57210129cda034b095d3f227298021feddda03f7" | ||
} |
@@ -246,2 +246,15 @@ import { GraphQLError, GraphQLFormattedError } from 'graphql'; | ||
const enrichedErrors = errors.map(error => enrichError(error, debug)); | ||
const makePrintable = error => { | ||
if (error instanceof Error) { | ||
// Error defines its `message` and other fields as non-enumerable, meaning JSON.stringigfy does not print them. | ||
const graphQLError = error as GraphQLFormattedError; | ||
return { | ||
message: graphQLError.message, | ||
...(graphQLError.locations && { locations: graphQLError.locations }), | ||
...(graphQLError.path && { path: graphQLError.path }), | ||
...(graphQLError.extensions && { extensions: graphQLError.extensions }), | ||
}; | ||
} | ||
return error; | ||
}; | ||
@@ -254,3 +267,3 @@ if (!formatter) { | ||
try { | ||
return formatter(error); | ||
return makePrintable(formatter(error)); | ||
} catch (err) { | ||
@@ -257,0 +270,0 @@ if (debug) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
25983
483
0