Built motion from commit 980b26c3.|2.6.29
[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 _0x3f2f=['status','send','exports','util','../config/logger','api','message','Internal\x20Server\x20Error','name','Error','inherits','Bad\x20Request','Forbidden','Entity\x20not\x20found','Message\x20sent\x20outside\x20a\x20valid\x20interval','Out\x20Of\x20Interval','details','OutOfInterval','Resource\x20Conflict','Conflict','stack','statusMessage'];(function(_0xbb091,_0x3fe7ee){var _0x467a04=function(_0x3a978d){while(--_0x3a978d){_0xbb091['push'](_0xbb091['shift']());}};_0x467a04(++_0x3fe7ee);}(_0x3f2f,0xb3));var _0xf3f2=function(_0x22bebf,_0x59ef05){_0x22bebf=_0x22bebf-0x0;var _0x261906=_0x3f2f[_0x22bebf];return _0x261906;};'use strict';var util=require(_0xf3f2('0x0'));var logger=require(_0xf3f2('0x1'))(_0xf3f2('0x2'));var APIError=function(_0x4042ba,_0x884450){this[_0xf3f2('0x3')]=_0x4042ba||_0xf3f2('0x4');this[_0xf3f2('0x5')]=_0x884450||_0xf3f2('0x6');util[_0xf3f2('0x7')](APIError,Error);};var APIBadRequestError=function(_0x1d092f){this[_0xf3f2('0x3')]=_0x1d092f||_0xf3f2('0x8');this[_0xf3f2('0x5')]='Bad\x20Request';util[_0xf3f2('0x7')](APIBadRequestError,APIError);};var APIForbiddenError=function(_0x473c91){this[_0xf3f2('0x3')]=_0x473c91||_0xf3f2('0x9');this['name']='Forbidden';util[_0xf3f2('0x7')](APIForbiddenError,APIError);};var APINotFoundError=function(_0x554291){this[_0xf3f2('0x3')]=_0x554291||_0xf3f2('0xa');this['name']='Not\x20Found';util[_0xf3f2('0x7')](APINotFoundError,APIError);};var APIOutOfIntervalError=function(_0x5a8b49){this[_0xf3f2('0x3')]=_0x5a8b49||_0xf3f2('0xb');this[_0xf3f2('0x5')]=_0xf3f2('0xc');this['code']=0x193;this[_0xf3f2('0xd')]={'type':_0xf3f2('0xe')};util[_0xf3f2('0x7')](APIOutOfIntervalError,APIError);};var APIConflictError=function(_0x1834ac){this[_0xf3f2('0x3')]=_0x1834ac||_0xf3f2('0xf');this[_0xf3f2('0x5')]='Conflict';util['inherits'](APIBadRequestError,APIError);};function getStatusCode(_0x34f7ad){switch(_0x34f7ad){case _0xf3f2('0x8'):return 0x190;case _0xf3f2('0x9'),_0xf3f2('0xc'):return 0x193;case'Not\x20Found':return 0x194;case _0xf3f2('0x10'):return 0x199;default:return 0x1f4;}}function getCustomStatusMessage(_0xccf2fc){if(_0xccf2fc===_0xf3f2('0xc'))return _0xccf2fc;return null;}function handleError(_0x196fd2){return function(_0x2faa41){logger['error'](_0x2faa41[_0xf3f2('0x11')]);var _0x1af174=getStatusCode(_0x2faa41['name']);var _0x1886b3=getCustomStatusMessage(_0x2faa41[_0xf3f2('0x5')]);if(_0x2faa41[_0xf3f2('0x5')]){delete _0x2faa41[_0xf3f2('0x5')];}if(_0x1886b3){_0x196fd2[_0xf3f2('0x12')]=_0x1886b3;}return _0x196fd2[_0xf3f2('0x13')](_0x1af174)[_0xf3f2('0x14')](_0x2faa41);};}module[_0xf3f2('0x15')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APIForbiddenError':APIForbiddenError,'APINotFoundError':APINotFoundError,'APIOutOfIntervalError':APIOutOfIntervalError,'APIConflict':APIConflictError,'handleError':handleError};