import { WrappingError } from "./Utils"; export class HttpError extends WrappingError { constructor(message, instructions, cause) { super(message, cause); this.instructions = instructions; } get name() { return this.constructor.name; } } export class BadRequestError extends HttpError { constructor(message, instructions, url, cause) { super(message, instructions, cause); this.url = url; } get errorCode() { return 400; } } export class ForbiddenHttpError extends BadRequestError { constructor(thing, url, cause) { super(`You don't have access to this ${thing}.`, `${url} doesn't belong to *you*.`, url, cause); } get errorCode() { return 403; } } export class NotFoundHttpError extends BadRequestError { constructor(thing, url, cause) { super(`${thing.charAt(0).toUpperCase()}${thing.substr(1)} not found.`, `${url} doesn't exist or was deleted.`, url, cause); } get errorCode() { return 404; } } export class ServerError extends HttpError { constructor(message, cause) { super(message, `Maybe you should contact us; see instructions below.`, cause); } get errorCode() { return 500; } } export class ServiceUnavailableHttpError extends ServerError { constructor(message, cause) { super(message, cause); } get errorCode() { return 503; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSHR0cEVycm9yLmpzIiwic291cmNlUm9vdCI6Ii4vIiwic291cmNlcyI6WyJIdHRwRXJyb3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFDLGFBQWEsRUFBQyxNQUFNLFNBQVMsQ0FBQztBQUV0QyxNQUFNLE9BQWdCLFNBQVUsU0FBUSxhQUFhO0lBR2pELFlBQVksT0FBZSxFQUFFLFlBQW9CLEVBQUUsS0FBYTtRQUM1RCxLQUFLLENBQUMsT0FBTyxFQUFFLEtBQUssQ0FBQyxDQUFDO1FBQ3RCLElBQUksQ0FBQyxZQUFZLEdBQUcsWUFBWSxDQUFDO0lBQ3JDLENBQUM7SUFFRCxJQUFJLElBQUk7UUFDSixPQUFPLElBQUksQ0FBQyxXQUFXLENBQUMsSUFBSSxDQUFDO0lBQ2pDLENBQUM7Q0FHSjtBQUVELE1BQU0sT0FBTyxlQUFnQixTQUFRLFNBQVM7SUFHMUMsWUFBWSxPQUFlLEVBQUUsWUFBb0I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IHN0cmluZywgY2F1c2U/OiBFcnJvcikge1xuICAgICAgICBzdXBlcihtZXNzYWdlLCBpbnN0cnVjdGlvbnMsIGNhdXNlKTtcbiAgICAgICAgdGhpcy51cmwgPSB1cmw7XG4gICAgfVxuXG4gICAgZ2V0IGVycm9yQ29kZSgpOiBudW1iZXIge1xuICAgICAgICByZXR1cm4gNDAwO1xuICAgIH1cbn1cblxuZXhwb3J0IGNsYXNzIEZvcmJpZGRlbkh0dHBFcnJvciBleHRlbmRzIEJhZFJlcXVlc3RFcnJvciB7XG4gICAgY29uc3RydWN0b3IodGhpbmc6IHN0cmluZywgdXJsOiBzdHJpbmcsIGNhdXNlPzogRXJyb3IpIHtcbiAgICAgICAgc3VwZXIoXG4gICAgICAgICAgICBgWW91IGRvbid0IGhhdmUgYWNjZXNzIHRvIHRoaXMgJHt0aGluZ30uYCxcbiAgICAgICAgICAgIGAke3VybH0gZG9lc24ndCBiZWxvbmcgdG8gKnlvdSouYCxcbiAgICAgICAgICAgIHVybCxcbiAgICAgICAgICAgIGNhdXNlXG4gICAgICAgICk7XG4gICAgfVxuXG4gICAgZ2V0IGVycm9yQ29kZSgpOiBudW1iZXIge1xuICAgICAgICByZXR1cm4gNDAzO1xuICAgIH1cbn1cblxuZXhwb3J0IGNsYXNzIE5vdEZvdW5kSHR0cEVycm9yIGV4dGVuZHMgQmFkUmVxdWVzdEVycm9yIHtcbiAgICBjb25zdHJ1Y3Rvcih0aGluZzogc3RyaW5nLCB1cmw6IHN0cmluZywgY2F1c2U/OiBFcnJvcikge1xuICAgICAgICBzdXBlcihcbiAgICAgICAgICAgIGAke3RoaW5nLmNoYXJBdCgwKS50b1VwcGVyQ2FzZSgpfSR7dGhpbmcuc3Vic3RyKDEpfSBub3QgZm91bmQuYCxcbiAgICAgICAgICAgIGAke3VybH0gZG9lc24ndCBleGlzdCBvciB3YXMgZGVsZXRlZC5gLFxuICAgICAgICAgICAgdXJsLFxuICAgICAgICAgICAgY2F1c2VcbiAgICAgICA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