UNPKG

wiz-frameworks

Version:

wizlong react framework

50 lines (39 loc) 2.47 kB
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var codeMessage = { 400: '发出的请求有错误,服务器没有进行新建或修改数据,的操作。', 401: '用户没有权限(令牌、用户名、密码错误)。', 403: '用户得到授权,但是访问是被禁止的。', 404: '发出的请求针对的是不存在的记录,服务器没有进行操作', 405: '禁用请求中指定的方法(方法禁用)', 406: '请求的格式不可得。', 410: '请求的资源被永久删除,且不会再得到的。', 422: '当创建一个对象时,发生一个验证错误。', 500: '服务器发生错误,请检查服务器', 502: '网关错误', 503: '服务不可用,服务器暂时过载或维护', 504: '网关超时', 0: '请求错误', invalidURL: '无效的请求URL', requestCanceled: '请求被提前取消了', timeout: '请求超时' }; var RequestError = function (_Error) { _inherits(RequestError, _Error); function RequestError(message) { var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; _classCallCheck(this, RequestError); var _this = _possibleConstructorReturn(this, (RequestError.__proto__ || Object.getPrototypeOf(RequestError)).call(this, message)); _this.name = 'RequestError'; console.log('Error code:', code); console.log('Error message:', message); console.log('Error codeMessage:', codeMessage[code]); _this.text = codeMessage[code]; _this.code = code; _this.date = new Date(); return _this; } return RequestError; }(Error); export default RequestError;