old_contents: export default function errorToHttpStatus(error) {
      const code = (error ? error.code : '') || '';
      switch (code) {
          case '23502':
              return 400;
          case '23503':
              return 409; // foreign_key_violation
          case '23505':
              return 409; // unique_violation
          case '42P01':
              return 404; // undefined table
          case '42501':
              return 404; // insufficient privilege
      }
  
      switch (code.substr(0, 2)) {
          case '08':
              return 503; // pg connection err
          case '09':
              return 500; // triggered action exception
          case '0L':
              return 403; // invalid grantor
          case '0P':
              return 403; // invalid role specification
  
  
          case '25':
              return 500; // invalid tx state
          case '28':
              return 403; // invalid auth specification
          case '2D':
              return 500; // invalid tx termination
          case '38':
              return 500; // external routine exception
          case '39':
              return 500; // external routine invocation
          case '3B':
              return 500; // savepoint exception
          case '40':
              return 500; // tx rollback
          case '53':
              return 503; // insufficient resources
          case '54':
              return 413; // too complex
          case '55':
              return 500; // obj not on prereq state
          case '57':
              return 500; // operator intervention
          case '58':
              return 500; // system error
          case 'F0':
              return 500; // conf file error
          case 'HV':
              return 500; // foreign data wrapper error
          case 'P0':
              return 500; // PL/pgSQL Error
          case 'XX':
              return 500; // internal Error
  
          default:
              return 400;
      }
  }
  
new_contents: const codes = {
      '23502': 400,
      '23503': 409, // foreign_key_violation
      '23505': 409, // unique_violation
      '42P01': 404, // undefined table
      '42501': 404, // insufficient privilege
  
      '08': 503, // pg connection err
      '09': 500, // triggered action exception
      '0L': 403, // invalid grantor
      '0P': 403, // invalid role specification
  
      '25': 500, // invalid tx state
      '28': 403, // invalid auth specification
      '2D': 500, // invalid tx termination
      '38': 500, // external routine exception
      '39': 500, // external routine invocation
      '3B': 500, // savepoint exception
      '40': 500, // tx rollback
      '53': 503, // insufficient resources
      '54': 413, // too complex
      '55': 500, // obj not on prereq state
      '57': 500, // operator intervention
      '58': 500, // system error
      'F0': 500, // conf file error
      'HV': 500, // foreign data wrapper error
      'P0': 500, // PL/pgSQL Error
      'XX': 500, // internal Error
  };
  
  export default function errorToHttpStatus(error) {
      const code = (error ? error.code : '') || '';
      for (let codePrefix of[code, code.substr(0, 2)])
          if (codePrefix in codes)
              return codes[codePrefix];
      /* istanbul ignore next */
      return 400;
  }
  
subject: Refactor errorToHttpStatus