Built motion from commit b0a9a629.|2.6.33
[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 _0xec62=['OutOfInterval','Conflict','Out\x20Of\x20Interval','error','stack','statusMessage','status','send','exports','../config/logger','api','message','Internal\x20Server\x20Error','name','Bad\x20Request','inherits','Forbidden','Entity\x20not\x20found','Not\x20Found','Message\x20sent\x20outside\x20a\x20valid\x20interval','details'];(function(_0x319cb9,_0x4b8d35){var _0x1735fc=function(_0x43b061){while(--_0x43b061){_0x319cb9['push'](_0x319cb9['shift']());}};_0x1735fc(++_0x4b8d35);}(_0xec62,0x144));var _0x2ec6=function(_0x598aa9,_0x36ce33){_0x598aa9=_0x598aa9-0x0;var _0x4ccbc3=_0xec62[_0x598aa9];return _0x4ccbc3;};'use strict';var util=require('util');var logger=require(_0x2ec6('0x0'))(_0x2ec6('0x1'));var APIError=function(_0xdc609c,_0x1b7b30){this[_0x2ec6('0x2')]=_0xdc609c||_0x2ec6('0x3');this[_0x2ec6('0x4')]=_0x1b7b30||'Error';util['inherits'](APIError,Error);};var APIBadRequestError=function(_0x1e4f33){this[_0x2ec6('0x2')]=_0x1e4f33||_0x2ec6('0x5');this[_0x2ec6('0x4')]=_0x2ec6('0x5');util[_0x2ec6('0x6')](APIBadRequestError,APIError);};var APIForbiddenError=function(_0x1e812d){this[_0x2ec6('0x2')]=_0x1e812d||_0x2ec6('0x7');this[_0x2ec6('0x4')]='Forbidden';util[_0x2ec6('0x6')](APIForbiddenError,APIError);};var APINotFoundError=function(_0x43df5d){this['message']=_0x43df5d||_0x2ec6('0x8');this[_0x2ec6('0x4')]=_0x2ec6('0x9');util[_0x2ec6('0x6')](APINotFoundError,APIError);};var APIOutOfIntervalError=function(_0x4a4821){this[_0x2ec6('0x2')]=_0x4a4821||_0x2ec6('0xa');this[_0x2ec6('0x4')]='Out\x20Of\x20Interval';this['code']=0x193;this[_0x2ec6('0xb')]={'type':_0x2ec6('0xc')};util['inherits'](APIOutOfIntervalError,APIError);};var APIConflictError=function(_0x60526a){this[_0x2ec6('0x2')]=_0x60526a||'Resource\x20Conflict';this[_0x2ec6('0x4')]=_0x2ec6('0xd');util[_0x2ec6('0x6')](APIBadRequestError,APIError);};function getStatusCode(_0x11c048){switch(_0x11c048){case _0x2ec6('0x5'):return 0x190;case _0x2ec6('0x7'),_0x2ec6('0xe'):return 0x193;case _0x2ec6('0x9'):return 0x194;case'Conflict':return 0x199;default:return 0x1f4;}}function getCustomStatusMessage(_0x93c672){if(_0x93c672===_0x2ec6('0xe'))return _0x93c672;return null;}function handleError(_0x4584a6){return function(_0x659b45){logger[_0x2ec6('0xf')](_0x659b45[_0x2ec6('0x10')]);var _0x5655f7=getStatusCode(_0x659b45[_0x2ec6('0x4')]);var _0x3df1c0=getCustomStatusMessage(_0x659b45[_0x2ec6('0x4')]);if(_0x659b45[_0x2ec6('0x4')]){delete _0x659b45[_0x2ec6('0x4')];}if(_0x3df1c0){_0x4584a6[_0x2ec6('0x11')]=_0x3df1c0;}return _0x4584a6[_0x2ec6('0x12')](_0x5655f7)[_0x2ec6('0x13')](_0x659b45);};}module[_0x2ec6('0x14')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APIForbiddenError':APIForbiddenError,'APINotFoundError':APINotFoundError,'APIOutOfIntervalError':APIOutOfIntervalError,'APIConflict':APIConflictError,'handleError':handleError};