INNER CODE UNIT · TypeScript
isInstance
thebigredgeek/apollo-errors · src/index.ts:90
export const isInstance = e => e instanceof ApolloError;
export const createError = (name: string, config: ErrorConfig) => {
assert(isObject(config), 'createError requires a config object as the second parameter');
assert(isString(config.message), 'createError requires a "message" property on the config object passed as the second parameter');
// NOTE: The first two parameters give to the constructor will always be name and config
// Parameters passed to the constructor when `new` is invoked will be passed as
// subsequent parameters.
return ApolloError.bind(null, name, config);
};
export const formatError = (error, returnNull = false): ErrorInfo => {
const originalError = error ? error.originalError || error : null;
if (!originalError) return returnNull ? null : error;
const { name } = originalError;