Source: components/restmodules/RestModuleAPI.js

/**
 * Rest API
 * @module RestModuleAPI
 */

export const errors = {
  invalidUUID: 'camera ID must be a valid UUID',
  httpErrorWithStatus: status => {
    if (status === 404) {
      return '404: object not found'
    }
    return 'Error ' + status;
  }
}

/**
 * Error handler
 * @param response
 * @returns {{ok}|Object}
 */
export function handleErrors(response) {
  if (response.ok) {
    return response;
  }

  throw new Error(errors.httpErrorWithStatus(response.status));
}