Built motion from commit 775e2a94.|2.6.3
[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 _0x54ef=['send','exports','util','../config/logger','api','message','Internal\x20Server\x20Error','name','Error','inherits','Bad\x20Request','Not\x20Found','Forbidden','OutOfInterval','error','stack','status'];(function(_0x277013,_0x33ca2b){var _0x5d6704=function(_0x1d34a9){while(--_0x1d34a9){_0x277013['push'](_0x277013['shift']());}};_0x5d6704(++_0x33ca2b);}(_0x54ef,0x112));var _0xf54e=function(_0x4d43a9,_0x8b9d85){_0x4d43a9=_0x4d43a9-0x0;var _0xf2be61=_0x54ef[_0x4d43a9];return _0xf2be61;};'use strict';var util=require(_0xf54e('0x0'));var logger=require(_0xf54e('0x1'))(_0xf54e('0x2'));var APIError=function(_0x5d180f,_0xd936f7){this[_0xf54e('0x3')]=_0x5d180f||_0xf54e('0x4');this[_0xf54e('0x5')]=_0xd936f7||_0xf54e('0x6');util[_0xf54e('0x7')](APIError,Error);};var APIBadRequestError=function(_0x12d43f){this['message']=_0x12d43f||'Bad\x20Request';this[_0xf54e('0x5')]=_0xf54e('0x8');util[_0xf54e('0x7')](APIBadRequestError,APIError);};var APINotFoundError=function(_0x561870){this[_0xf54e('0x3')]=_0x561870||'Entity\x20not\x20found';this[_0xf54e('0x5')]=_0xf54e('0x9');util['inherits'](APINotFoundError,APIError);};function getStatusCode(_0x26fc3e){switch(_0x26fc3e){case _0xf54e('0x8'):return 0x190;case _0xf54e('0xa'),_0xf54e('0xb'):return 0x193;case'Not\x20Found':return 0x194;default:return 0x1f4;}}function handleError(_0x558502){return function(_0xc939ab){logger[_0xf54e('0xc')](_0xc939ab[_0xf54e('0xd')]);var _0x553759=getStatusCode(_0xc939ab[_0xf54e('0x5')]);if(_0xc939ab['name'])delete _0xc939ab['name'];return _0x558502[_0xf54e('0xe')](_0x553759)[_0xf54e('0xf')](_0xc939ab);};}module[_0xf54e('0x10')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError};