forked from hibas123/SecureFileWrapper
adding type property on errors
This commit is contained in:
parent
cc36f7c1bd
commit
8e49bd3218
3
index.d.ts
vendored
3
index.d.ts
vendored
@ -31,11 +31,14 @@ export default class SecureFile {
|
||||
history(id: string): Promise<History>;
|
||||
}
|
||||
export declare class Unauthorized extends Error {
|
||||
type: string;
|
||||
constructor();
|
||||
}
|
||||
export declare class NotFound extends Error {
|
||||
type: string;
|
||||
constructor();
|
||||
}
|
||||
export declare class BadRequest extends Error {
|
||||
type: string;
|
||||
constructor();
|
||||
}
|
||||
|
12
index.js
12
index.js
@ -270,7 +270,9 @@ exports.default = SecureFile;
|
||||
var Unauthorized = /** @class */ (function (_super) {
|
||||
__extends(Unauthorized, _super);
|
||||
function Unauthorized() {
|
||||
return _super.call(this, "Not authorized") || this;
|
||||
var _this = _super.call(this, "Not authorized") || this;
|
||||
_this.type = "unauthorized";
|
||||
return _this;
|
||||
}
|
||||
return Unauthorized;
|
||||
}(Error));
|
||||
@ -278,7 +280,9 @@ exports.Unauthorized = Unauthorized;
|
||||
var NotFound = /** @class */ (function (_super) {
|
||||
__extends(NotFound, _super);
|
||||
function NotFound() {
|
||||
return _super.call(this, "Not found") || this;
|
||||
var _this = _super.call(this, "Not found") || this;
|
||||
_this.type = "notfound";
|
||||
return _this;
|
||||
}
|
||||
return NotFound;
|
||||
}(Error));
|
||||
@ -286,7 +290,9 @@ exports.NotFound = NotFound;
|
||||
var BadRequest = /** @class */ (function (_super) {
|
||||
__extends(BadRequest, _super);
|
||||
function BadRequest() {
|
||||
return _super.call(this, "Bad request") || this;
|
||||
var _this = _super.call(this, "Bad request") || this;
|
||||
_this.type = "badrequest";
|
||||
return _this;
|
||||
}
|
||||
return BadRequest;
|
||||
}(Error));
|
||||
|
6
index.ts
6
index.ts
@ -139,20 +139,26 @@ export default class SecureFile {
|
||||
}
|
||||
|
||||
export class Unauthorized extends Error {
|
||||
type: string;
|
||||
constructor() {
|
||||
super("Not authorized");
|
||||
this.type = "unauthorized"
|
||||
}
|
||||
}
|
||||
|
||||
export class NotFound extends Error {
|
||||
type: string;
|
||||
constructor() {
|
||||
super("Not found");
|
||||
this.type = "notfound"
|
||||
}
|
||||
}
|
||||
|
||||
export class BadRequest extends Error {
|
||||
type: string;
|
||||
constructor() {
|
||||
super("Bad request");
|
||||
this.type = "badrequest"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user