apollo-error-converter
Version:
Global Apollo Server Error handling made easy. Remove verbose and repetitive resolver / data source Error handling. Ensures no implementation details are ever leaked while preserving internal Error logging.
14 lines (12 loc) • 382 B
JavaScript
/**
* Retrieves a MapItem for converting the Error
* - the MapItem can be associated by error.[name, code, type]
* @param {Error} originalError original Error object
*/
function getMapItem(originalError) {
const { name, code, type } = originalError;
return (
this.errorMap[name] || this.errorMap[code] || this.errorMap[type] || null
);
}
module.exports = getMapItem;