Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / errors / api.js
index 2bf95a7..df65a38 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xea82=['api','message','name','inherits','Bad\x20Request','Forbidden','Entity\x20not\x20found','Not\x20Found','Message\x20sent\x20outside\x20a\x20valid\x20interval','Out\x20Of\x20Interval','code','details','OutOfInterval','Resource\x20Conflict','Conflict','error','statusMessage','util'];(function(_0x4641b3,_0xad3d46){var _0xbcd73b=function(_0x47fe25){while(--_0x47fe25){_0x4641b3['push'](_0x4641b3['shift']());}};_0xbcd73b(++_0xad3d46);}(_0xea82,0x131));var _0x2ea8=function(_0x5d93a4,_0x10fca8){_0x5d93a4=_0x5d93a4-0x0;var _0x17b491=_0xea82[_0x5d93a4];return _0x17b491;};'use strict';var util=require(_0x2ea8('0x0'));var logger=require('../config/logger')(_0x2ea8('0x1'));var APIError=function(_0x1e5c10,_0x2a74f7){this[_0x2ea8('0x2')]=_0x1e5c10||'Internal\x20Server\x20Error';this[_0x2ea8('0x3')]=_0x2a74f7||'Error';util[_0x2ea8('0x4')](APIError,Error);};var APIBadRequestError=function(_0x19148){this[_0x2ea8('0x2')]=_0x19148||_0x2ea8('0x5');this[_0x2ea8('0x3')]=_0x2ea8('0x5');util[_0x2ea8('0x4')](APIBadRequestError,APIError);};var APIForbiddenError=function(_0x13aa3b){this[_0x2ea8('0x2')]=_0x13aa3b||_0x2ea8('0x6');this[_0x2ea8('0x3')]=_0x2ea8('0x6');util[_0x2ea8('0x4')](APIForbiddenError,APIError);};var APINotFoundError=function(_0x5895f1){this['message']=_0x5895f1||_0x2ea8('0x7');this[_0x2ea8('0x3')]=_0x2ea8('0x8');util[_0x2ea8('0x4')](APINotFoundError,APIError);};var APIOutOfIntervalError=function(_0xfee93b){this[_0x2ea8('0x2')]=_0xfee93b||_0x2ea8('0x9');this['name']=_0x2ea8('0xa');this[_0x2ea8('0xb')]=0x193;this[_0x2ea8('0xc')]={'type':_0x2ea8('0xd')};util['inherits'](APIOutOfIntervalError,APIError);};var APIConflictError=function(_0x49c729){this[_0x2ea8('0x2')]=_0x49c729||_0x2ea8('0xe');this[_0x2ea8('0x3')]=_0x2ea8('0xf');util[_0x2ea8('0x4')](APIBadRequestError,APIError);};function getStatusCode(_0x3fd813){switch(_0x3fd813){case _0x2ea8('0x5'):return 0x190;case _0x2ea8('0x6'),_0x2ea8('0xa'):return 0x193;case'Not\x20Found':return 0x194;case'Conflict':return 0x199;default:return 0x1f4;}}function getCustomStatusMessage(_0x1afc64){if(_0x1afc64==='Out\x20Of\x20Interval')return _0x1afc64;return null;}function handleError(_0x106528){return function(_0xb1e33f){logger[_0x2ea8('0x10')](_0xb1e33f['stack']);var _0x17c724=getStatusCode(_0xb1e33f['name']);var _0x312ca7=getCustomStatusMessage(_0xb1e33f[_0x2ea8('0x3')]);if(_0xb1e33f['name']){delete _0xb1e33f['name'];}if(_0x312ca7){_0x106528[_0x2ea8('0x11')]=_0x312ca7;}return _0x106528['status'](_0x17c724)['send'](_0xb1e33f);};}module['exports']={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APIForbiddenError':APIForbiddenError,'APINotFoundError':APINotFoundError,'APIOutOfIntervalError':APIOutOfIntervalError,'APIConflict':APIConflictError,'handleError':handleError};
\ No newline at end of file
+var _0x2ead=['send','exports','../config/logger','api','message','name','Error','inherits','Bad\x20Request','Forbidden','Entity\x20not\x20found','Out\x20Of\x20Interval','code','details','OutOfInterval','stack','statusMessage'];(function(_0x5a2d3f,_0x27b04e){var _0x5c65d8=function(_0x2d1965){while(--_0x2d1965){_0x5a2d3f['push'](_0x5a2d3f['shift']());}};_0x5c65d8(++_0x27b04e);}(_0x2ead,0xdf));var _0xd2ea=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2ead[_0x3dd15e];return _0x231fd0;};'use strict';var util=require('util');var logger=require(_0xd2ea('0x0'))(_0xd2ea('0x1'));var APIError=function(_0x122772,_0x5afe18){this[_0xd2ea('0x2')]=_0x122772||'Internal\x20Server\x20Error';this[_0xd2ea('0x3')]=_0x5afe18||_0xd2ea('0x4');util[_0xd2ea('0x5')](APIError,Error);};var APIBadRequestError=function(_0x55c37b){this[_0xd2ea('0x2')]=_0x55c37b||_0xd2ea('0x6');this[_0xd2ea('0x3')]=_0xd2ea('0x6');util[_0xd2ea('0x5')](APIBadRequestError,APIError);};var APIForbiddenError=function(_0x53ea93){this[_0xd2ea('0x2')]=_0x53ea93||_0xd2ea('0x7');this[_0xd2ea('0x3')]=_0xd2ea('0x7');util[_0xd2ea('0x5')](APIForbiddenError,APIError);};var APINotFoundError=function(_0x3c273f){this[_0xd2ea('0x2')]=_0x3c273f||_0xd2ea('0x8');this['name']='Not\x20Found';util['inherits'](APINotFoundError,APIError);};var APIOutOfIntervalError=function(_0x2b17db){this[_0xd2ea('0x2')]=_0x2b17db||'Message\x20sent\x20outside\x20a\x20valid\x20interval';this['name']=_0xd2ea('0x9');this[_0xd2ea('0xa')]=0x193;this[_0xd2ea('0xb')]={'type':_0xd2ea('0xc')};util[_0xd2ea('0x5')](APIOutOfIntervalError,APIError);};var APIConflictError=function(_0x2ca59a){this[_0xd2ea('0x2')]=_0x2ca59a||'Resource\x20Conflict';this[_0xd2ea('0x3')]='Conflict';util['inherits'](APIBadRequestError,APIError);};function getStatusCode(_0x398d6d){switch(_0x398d6d){case'Bad\x20Request':return 0x190;case _0xd2ea('0x7'),_0xd2ea('0x9'):return 0x193;case'Not\x20Found':return 0x194;case'Conflict':return 0x199;default:return 0x1f4;}}function getCustomStatusMessage(_0x1fed33){if(_0x1fed33==='Out\x20Of\x20Interval')return _0x1fed33;return null;}function handleError(_0x16e169){return function(_0x5adf88){logger['error'](_0x5adf88[_0xd2ea('0xd')]);var _0x33e7da=getStatusCode(_0x5adf88[_0xd2ea('0x3')]);var _0x28e039=getCustomStatusMessage(_0x5adf88['name']);if(_0x5adf88[_0xd2ea('0x3')]){delete _0x5adf88[_0xd2ea('0x3')];}if(_0x28e039){_0x16e169[_0xd2ea('0xe')]=_0x28e039;}return _0x16e169['status'](_0x33e7da)[_0xd2ea('0xf')](_0x5adf88);};}module[_0xd2ea('0x10')]={'APIError':APIError,'APIBadRequestError':APIBadRequestError,'APIForbiddenError':APIForbiddenError,'APINotFoundError':APINotFoundError,'APIOutOfIntervalError':APIOutOfIntervalError,'APIConflict':APIConflictError,'handleError':handleError};
\ No newline at end of file