Built motion from commit 00bf23f6.|2.6.16
[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 _0xb43b=['error','status','util','../config/logger','message','name','Error','inherits','Entity\x20not\x20found','Forbidden','OutOfInterval','Not\x20Found'];(function(_0x22331f,_0xa28899){var _0x4a40e3=function(_0x2bb43b){while(--_0x2bb43b){_0x22331f['push'](_0x22331f['shift']());}};_0x4a40e3(++_0xa28899);}(_0xb43b,0x1b2));var _0xbb43=function(_0x5c7877,_0x2250d9){_0x5c7877=_0x5c7877-0x0;var _0x244250=_0xb43b[_0x5c7877];return _0x244250;};'use strict';var util=require(_0xbb43('0x0'));var logger=require(_0xbb43('0x1'))('api');var APIError=function(_0x1bdcfc,_0x1995f8){this[_0xbb43('0x2')]=_0x1bdcfc||'Internal\x20Server\x20Error';this[_0xbb43('0x3')]=_0x1995f8||_0xbb43('0x4');util[_0xbb43('0x5')](APIError,Error);};var APIBadRequestError=function(_0x16432a){this['message']=_0x16432a||'Bad\x20Request';this[_0xbb43('0x3')]='Bad\x20Request';util[_0xbb43('0x5')](APIBadRequestError,APIError);};var APINotFoundError=function(_0x1ccd49){this[_0xbb43('0x2')]=_0x1ccd49||_0xbb43('0x6');this[_0xbb43('0x3')]='Not\x20Found';util[_0xbb43('0x5')](APINotFoundError,APIError);};function getStatusCode(_0xf54ac5){switch(_0xf54ac5){case'Bad\x20Request':return 0x190;case _0xbb43('0x7'),_0xbb43('0x8'):return 0x193;case _0xbb43('0x9'):return 0x194;default:return 0x1f4;}}function handleError(_0x5e3611){return function(_0xfac791){logger[_0xbb43('0xa')](_0xfac791['stack']);var _0x36a473=getStatusCode(_0xfac791[_0xbb43('0x3')]);if(_0xfac791['name'])delete _0xfac791['name'];return _0x5e3611[_0xbb43('0xb')](_0x36a473)['send'](_0xfac791);};}module['exports']={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError};