Built motion from commit f6d7e26c.|2.6.14
[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 _0xda3f=['inherits','message','Bad\x20Request','Entity\x20not\x20found','name','Not\x20Found','Forbidden','OutOfInterval','error','stack','send','exports','../config/logger','api','Internal\x20Server\x20Error','Error'];(function(_0x41179d,_0xafc087){var _0xb4d26c=function(_0x419fbf){while(--_0x419fbf){_0x41179d['push'](_0x41179d['shift']());}};_0xb4d26c(++_0xafc087);}(_0xda3f,0xec));var _0xfda3=function(_0x2d4185,_0xcaf731){_0x2d4185=_0x2d4185-0x0;var _0x23f544=_0xda3f[_0x2d4185];return _0x23f544;};'use strict';var util=require('util');var logger=require(_0xfda3('0x0'))(_0xfda3('0x1'));var APIError=function(_0x534697,_0x5299b0){this['message']=_0x534697||_0xfda3('0x2');this['name']=_0x5299b0||_0xfda3('0x3');util[_0xfda3('0x4')](APIError,Error);};var APIBadRequestError=function(_0x516500){this[_0xfda3('0x5')]=_0x516500||_0xfda3('0x6');this['name']='Bad\x20Request';util[_0xfda3('0x4')](APIBadRequestError,APIError);};var APINotFoundError=function(_0x42476a){this[_0xfda3('0x5')]=_0x42476a||_0xfda3('0x7');this[_0xfda3('0x8')]=_0xfda3('0x9');util[_0xfda3('0x4')](APINotFoundError,APIError);};function getStatusCode(_0x1b1ea6){switch(_0x1b1ea6){case _0xfda3('0x6'):return 0x190;case _0xfda3('0xa'),_0xfda3('0xb'):return 0x193;case _0xfda3('0x9'):return 0x194;default:return 0x1f4;}}function handleError(_0x4d7841){return function(_0xe933f5){logger[_0xfda3('0xc')](_0xe933f5[_0xfda3('0xd')]);var _0x11afc1=getStatusCode(_0xe933f5[_0xfda3('0x8')]);if(_0xe933f5['name'])delete _0xe933f5[_0xfda3('0x8')];return _0x4d7841['status'](_0x11afc1)[_0xfda3('0xe')](_0xe933f5);};}module[_0xfda3('0xf')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError};