Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (err: any) => {
if (err && err.extensions != null) {
if (removeUserStack && err.extensions.exception) {
delete err.extensions.exception.stack;
}
return err;
}
const { statusCode, message, code } = ts.parseErrorInfo(err);
let error: any;
if (statusCode >= 400 && statusCode < 500) {
if (statusCode === 422) {
error = new apollo.ValidationError(message);
} else if (statusCode === 401) {
error = new apollo.AuthenticationError(message);
} else if (statusCode === 403) {
error = new apollo.ForbiddenError(message);
} else {
error = new apollo.UserInputError(message);
}
if (err && err.stack) {
if (removeUserStack) {
error.stack = undefined;
} else {
error.stack = err.stack;
}
}
} else {