Built motion from commit da617fac.|2.6.6
[motion2.git] / server / errors / api.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x6f0d=['../config/logger','api','Internal\x20Server\x20Error','name','Error','inherits','Bad\x20Request','message','Not\x20Found','Forbidden','error','status','send','exports'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0x6f0d,0x16c));var _0xd6f0=function(_0x4fbfdc,_0xf529dc){_0x4fbfdc=_0x4fbfdc-0x0;var _0x35fa98=_0x6f0d[_0x4fbfdc];return _0x35fa98;};'use strict';var util=require('util');var logger=require(_0xd6f0('0x0'))(_0xd6f0('0x1'));var APIError=function(_0xd1480,_0x107a8c){this['message']=_0xd1480||_0xd6f0('0x2');this[_0xd6f0('0x3')]=_0x107a8c||_0xd6f0('0x4');util[_0xd6f0('0x5')](APIError,Error);};var APIBadRequestError=function(_0x3a757f){this['message']=_0x3a757f||_0xd6f0('0x6');this['name']=_0xd6f0('0x6');util[_0xd6f0('0x5')](APIBadRequestError,APIError);};var APINotFoundError=function(_0x8b89a9){this[_0xd6f0('0x7')]=_0x8b89a9||'Entity\x20not\x20found';this['name']=_0xd6f0('0x8');util[_0xd6f0('0x5')](APINotFoundError,APIError);};function getStatusCode(_0x2854cd){switch(_0x2854cd){case _0xd6f0('0x6'):return 0x190;case _0xd6f0('0x9'),'OutOfInterval':return 0x193;case _0xd6f0('0x8'):return 0x194;default:return 0x1f4;}}function handleError(_0xee144c){return function(_0x329f69){logger[_0xd6f0('0xa')](_0x329f69['stack']);var _0x1ce8d5=getStatusCode(_0x329f69[_0xd6f0('0x3')]);if(_0x329f69[_0xd6f0('0x3')])delete _0x329f69[_0xd6f0('0x3')];return _0xee144c[_0xd6f0('0xb')](_0x1ce8d5)[_0xd6f0('0xc')](_0x329f69);};}module[_0xd6f0('0xd')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError};