4979764e99ae776d61c4803e6d47622e67c88c76
[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 _0xd8b0=['Bad\x20Request','Not\x20Found','Forbidden','OutOfInterval','stack','status','send','exports','util','../config/logger','message','Internal\x20Server\x20Error','name','Error','inherits'];(function(_0x3a9661,_0x530b12){var _0x5bb119=function(_0x1278f){while(--_0x1278f){_0x3a9661['push'](_0x3a9661['shift']());}};_0x5bb119(++_0x530b12);}(_0xd8b0,0xad));var _0x0d8b=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0xd8b0[_0x20a584];return _0x4b41a8;};'use strict';var util=require(_0x0d8b('0x0'));var logger=require(_0x0d8b('0x1'))('api');var APIError=function(_0x585166,_0x4b72b0){this[_0x0d8b('0x2')]=_0x585166||_0x0d8b('0x3');this[_0x0d8b('0x4')]=_0x4b72b0||_0x0d8b('0x5');util[_0x0d8b('0x6')](APIError,Error);};var APIBadRequestError=function(_0x577834){this['message']=_0x577834||_0x0d8b('0x7');this[_0x0d8b('0x4')]=_0x0d8b('0x7');util['inherits'](APIBadRequestError,APIError);};var APINotFoundError=function(_0x413284){this[_0x0d8b('0x2')]=_0x413284||'Entity\x20not\x20found';this[_0x0d8b('0x4')]=_0x0d8b('0x8');util[_0x0d8b('0x6')](APINotFoundError,APIError);};function getStatusCode(_0x1f4800){switch(_0x1f4800){case _0x0d8b('0x7'):return 0x190;case _0x0d8b('0x9'),_0x0d8b('0xa'):return 0x193;case _0x0d8b('0x8'):return 0x194;default:return 0x1f4;}}function handleError(_0x48fa16){return function(_0x3c4bfa){logger['error'](_0x3c4bfa[_0x0d8b('0xb')]);var _0xc574a3=getStatusCode(_0x3c4bfa[_0x0d8b('0x4')]);if(_0x3c4bfa[_0x0d8b('0x4')])delete _0x3c4bfa[_0x0d8b('0x4')];return _0x48fa16[_0x0d8b('0xc')](_0xc574a3)[_0x0d8b('0xd')](_0x3c4bfa);};}module[_0x0d8b('0xe')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError};