48f42500981bbd4fcf89c76ba3c2c1d4851e8a94
[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 _0xf109=['status','exports','util','../config/logger','api','Internal\x20Server\x20Error','name','Error','inherits','message','Bad\x20Request','Entity\x20not\x20found','Not\x20Found','Forbidden','OutOfInterval','error','stack'];(function(_0xa388a2,_0x40bde6){var _0x7ce7f6=function(_0x5a242a){while(--_0x5a242a){_0xa388a2['push'](_0xa388a2['shift']());}};_0x7ce7f6(++_0x40bde6);}(_0xf109,0xce));var _0x9f10=function(_0x4ae6ef,_0xc2af80){_0x4ae6ef=_0x4ae6ef-0x0;var _0x3cbb4e=_0xf109[_0x4ae6ef];return _0x3cbb4e;};'use strict';var util=require(_0x9f10('0x0'));var logger=require(_0x9f10('0x1'))(_0x9f10('0x2'));var APIError=function(_0x5d2950,_0x5b381d){this['message']=_0x5d2950||_0x9f10('0x3');this[_0x9f10('0x4')]=_0x5b381d||_0x9f10('0x5');util[_0x9f10('0x6')](APIError,Error);};var APIBadRequestError=function(_0x4027f4){this[_0x9f10('0x7')]=_0x4027f4||_0x9f10('0x8');this[_0x9f10('0x4')]=_0x9f10('0x8');util[_0x9f10('0x6')](APIBadRequestError,APIError);};var APINotFoundError=function(_0x3fd82f){this['message']=_0x3fd82f||_0x9f10('0x9');this[_0x9f10('0x4')]=_0x9f10('0xa');util[_0x9f10('0x6')](APINotFoundError,APIError);};function getStatusCode(_0x325f22){switch(_0x325f22){case'Bad\x20Request':return 0x190;case _0x9f10('0xb'),_0x9f10('0xc'):return 0x193;case _0x9f10('0xa'):return 0x194;default:return 0x1f4;}}function handleError(_0x4e577d){return function(_0x50215f){logger[_0x9f10('0xd')](_0x50215f[_0x9f10('0xe')]);var _0x407336=getStatusCode(_0x50215f['name']);if(_0x50215f[_0x9f10('0x4')])delete _0x50215f[_0x9f10('0x4')];return _0x4e577d[_0x9f10('0xf')](_0x407336)['send'](_0x50215f);};}module[_0x9f10('0x10')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError};