"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

/**
 * @param {number} httpStatus
 * @param {{
 *   handleNotAuthorized: () => any
 *   handleNoAuthentication: () => any
 * }}
 * @returns {void}
 */
var _default = (httpStatus, {
  handleNoAuthentication,
  handleNotAuthorized
}) => {
  if (httpStatus >= 400) {
    if (httpStatus === 404) {
      throw Error('NOT_FOUND');
    } else if (httpStatus === 401) {
      handleNoAuthentication();
      throw Error('NO_AUTHENTICATION');
    } else if (httpStatus === 403) {
      handleNotAuthorized();
      throw Error('NOT_AUTHORIZED');
    } else if (httpStatus === 409) {
      throw Error('CONFLICT');
    } else {
      throw Error('REQUEST_ERROR_' + httpStatus);
    }
  }
};

exports.default = _default;