import statuses from "./status.js" const errorHandler = (e, obj) => { switch (e.code) { case '23505': throw { status: statuses.duplicate, message: `Such ${obj} already exists` } case '22007': throw { status: statuses.invalid_syntax, message: `Invalid syntax in ${obj}` } case '22001': throw { status: statuses.invalid_syntax, message: `Value too long (${obj})` } default: throw { status: statuses.unknown, message: `Unknown error. Please, report to the developer`, original: e } } }; export default errorHandler;