// What can go wrong serving a blob, by whose fault it is: each kind is one // HTTP status, and says how long the answer may be cached. export class HttpError extends Error { readonly status: number; /** The Cache-Control the error response carries. */ readonly cache: string; constructor(status: number, message: string, cache: string) { super(message); this.status = status; this.cache = cache; } } /** The URL can never name a blob: cacheable for a day. */ export class BadRequest extends HttpError { constructor(message: string) { super(400, message, 'public, max-age=86400'); } } /** * The account or the blob does not exist. Cached briefly: a blob may be * uploaded moments before the record pointing at it is published. */ export class NotFound extends HttpError { constructor(message: string) { super(404, message, 'public, max-age=300'); } } /** The PDS, the PLC directory or a DID's host failed us. Never cached. */ export class Upstream extends HttpError { constructor(message: string) { super(502, message, 'no-store'); } }