Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / errors / api.js
index e109022..ac8a3a6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdace=['send','exports','util','api','Internal\x20Server\x20Error','name','Error','inherits','message','Bad\x20Request','Not\x20Found','Forbidden','OutOfInterval','error','status'];(function(_0x4a4f2e,_0x176cc3){var _0x31b036=function(_0x370520){while(--_0x370520){_0x4a4f2e['push'](_0x4a4f2e['shift']());}};_0x31b036(++_0x176cc3);}(_0xdace,0xc5));var _0xedac=function(_0x45fc6a,_0x166adb){_0x45fc6a=_0x45fc6a-0x0;var _0x14bcfd=_0xdace[_0x45fc6a];return _0x14bcfd;};'use strict';var util=require(_0xedac('0x0'));var logger=require('../config/logger')(_0xedac('0x1'));var APIError=function(_0x13adb5,_0x46eba0){this['message']=_0x13adb5||_0xedac('0x2');this[_0xedac('0x3')]=_0x46eba0||_0xedac('0x4');util[_0xedac('0x5')](APIError,Error);};var APIBadRequestError=function(_0x5a97c0){this[_0xedac('0x6')]=_0x5a97c0||_0xedac('0x7');this[_0xedac('0x3')]='Bad\x20Request';util[_0xedac('0x5')](APIBadRequestError,APIError);};var APINotFoundError=function(_0x21440e){this[_0xedac('0x6')]=_0x21440e||'Entity\x20not\x20found';this[_0xedac('0x3')]=_0xedac('0x8');util[_0xedac('0x5')](APINotFoundError,APIError);};function getStatusCode(_0x4af030){switch(_0x4af030){case'Bad\x20Request':return 0x190;case _0xedac('0x9'),_0xedac('0xa'):return 0x193;case'Not\x20Found':return 0x194;default:return 0x1f4;}}function handleError(_0x4d6a29){return function(_0x4db2ad){logger[_0xedac('0xb')](_0x4db2ad['stack']);var _0x261401=getStatusCode(_0x4db2ad['name']);if(_0x4db2ad[_0xedac('0x3')])delete _0x4db2ad[_0xedac('0x3')];return _0x4d6a29[_0xedac('0xc')](_0x261401)[_0xedac('0xd')](_0x4db2ad);};}module[_0xedac('0xe')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APINotFoundError':APINotFoundError,'handleError':handleError};
\ No newline at end of file
+var _0xa2e1=['Error','name','Bad\x20Request','inherits','Forbidden','Entity\x20not\x20found','Not\x20Found','Out\x20Of\x20Interval','details','OutOfInterval','Resource\x20Conflict','Conflict','error','stack','statusMessage','status','send','exports','../config/logger','api','message','Internal\x20Server\x20Error'];(function(_0x1804f9,_0x9de9cb){var _0x43e65b=function(_0x1f6ebc){while(--_0x1f6ebc){_0x1804f9['push'](_0x1804f9['shift']());}};_0x43e65b(++_0x9de9cb);}(_0xa2e1,0x188));var _0x1a2e=function(_0x20eaec,_0x40dfab){_0x20eaec=_0x20eaec-0x0;var _0x2de673=_0xa2e1[_0x20eaec];return _0x2de673;};'use strict';var util=require('util');var logger=require(_0x1a2e('0x0'))(_0x1a2e('0x1'));var APIError=function(_0x1c61b1,_0x4f7747){this[_0x1a2e('0x2')]=_0x1c61b1||_0x1a2e('0x3');this['name']=_0x4f7747||_0x1a2e('0x4');util['inherits'](APIError,Error);};var APIBadRequestError=function(_0x3a54a5){this[_0x1a2e('0x2')]=_0x3a54a5||'Bad\x20Request';this[_0x1a2e('0x5')]=_0x1a2e('0x6');util[_0x1a2e('0x7')](APIBadRequestError,APIError);};var APIForbiddenError=function(_0x661804){this[_0x1a2e('0x2')]=_0x661804||_0x1a2e('0x8');this[_0x1a2e('0x5')]=_0x1a2e('0x8');util[_0x1a2e('0x7')](APIForbiddenError,APIError);};var APINotFoundError=function(_0x377068){this[_0x1a2e('0x2')]=_0x377068||_0x1a2e('0x9');this[_0x1a2e('0x5')]=_0x1a2e('0xa');util[_0x1a2e('0x7')](APINotFoundError,APIError);};var APIOutOfIntervalError=function(_0x59bbf1){this[_0x1a2e('0x2')]=_0x59bbf1||'Message\x20sent\x20outside\x20a\x20valid\x20interval';this[_0x1a2e('0x5')]=_0x1a2e('0xb');this['code']=0x193;this[_0x1a2e('0xc')]={'type':_0x1a2e('0xd')};util[_0x1a2e('0x7')](APIOutOfIntervalError,APIError);};var APIConflictError=function(_0x3b1ddf){this[_0x1a2e('0x2')]=_0x3b1ddf||_0x1a2e('0xe');this[_0x1a2e('0x5')]=_0x1a2e('0xf');util[_0x1a2e('0x7')](APIBadRequestError,APIError);};function getStatusCode(_0x1f3352){switch(_0x1f3352){case'Bad\x20Request':return 0x190;case'Forbidden',_0x1a2e('0xb'):return 0x193;case _0x1a2e('0xa'):return 0x194;case'Conflict':return 0x199;default:return 0x1f4;}}function getCustomStatusMessage(_0x2096bf){if(_0x2096bf===_0x1a2e('0xb'))return _0x2096bf;return null;}function handleError(_0x5ea6b1){return function(_0x5530d8){logger[_0x1a2e('0x10')](_0x5530d8[_0x1a2e('0x11')]);var _0x17b1b9=getStatusCode(_0x5530d8[_0x1a2e('0x5')]);var _0x5979ca=getCustomStatusMessage(_0x5530d8[_0x1a2e('0x5')]);if(_0x5530d8[_0x1a2e('0x5')]){delete _0x5530d8[_0x1a2e('0x5')];}if(_0x5979ca){_0x5ea6b1[_0x1a2e('0x12')]=_0x5979ca;}return _0x5ea6b1[_0x1a2e('0x13')](_0x17b1b9)[_0x1a2e('0x14')](_0x5530d8);};}module[_0x1a2e('0x15')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APIForbiddenError':APIForbiddenError,'APINotFoundError':APINotFoundError,'APIOutOfIntervalError':APIOutOfIntervalError,'APIConflict':APIConflictError,'handleError':handleError};
\ No newline at end of file