vormiaqueryjs
Version:
Vormia Query Js - A npm package for query management with VormiaPHP laravel Backend application
3 lines (2 loc) • 1.16 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t extends Error{constructor(r,s,a,e){super(r),this.name="VormiaError",this.status=s||a&&a.status,this.response=a,this.code=e,this.data=a&&a.data,Error.captureStackTrace&&Error.captureStackTrace(this,t)}isNetworkError(){return"NETWORK_ERROR"===this.code||!this.status}isServerError(){return!!(this.status&&this.status>=500)}isClientError(){return!!(this.status&&this.status>=400&&this.status<500)}isUnauthenticated(){return 401===this.status}isUnauthorized(){return 403===this.status}isNotFound(){return 404===this.status}isValidationError(){return 422===this.status}getErrorMessage(){var t;if(this.data){if("string"==typeof this.data)return this.data;if(this.data.message)return this.data.message;if(this.data.error)return this.data.error;if(Array.isArray(this.data.errors))return(null==(t=this.data.errors[0])?void 0:t.message)||this.message}return this.message||"An unknown error occurred"}getValidationErrors(){return 422===this.status&&this.data&&"object"==typeof this.data?this.data.errors||this.data:null}}exports.VormiaError=t;
//# sourceMappingURL=VormiaError.js.map