UNPKG

robert

Version:

A generic shitty http client in nod.js

53 lines (52 loc) 1.45 kB
export class RobertError extends Error { url; options; constructor(url, options, message) { super("RobertError: " + message); this.url = url; this.options = options; } } export class RedirectError extends RobertError { constructor(url, options) { super(url, options, "URL redirected over limit"); } } export class TimeoutError extends RobertError { time; constructor(url, options, time) { super(url, options, "Request timed out after " + time + "ms"); this.time = time; } } export class ParseError extends RobertError { format; error; constructor(url, options, format, error) { super(url, options, "Could not parse body: (" + format + ") " + error.message); this.format = format; this.error = error; } } export class ResponseError extends RobertError { /**@deprecated */ code; /**@deprecated */ text; /**@deprecated */ body; status; statusText; headers; data; constructor(url, options, status, statusText, headers, data) { super(url, options, "URL responded with status " + status + ": " + statusText); this.code = status; this.status = status; this.text = statusText; this.statusText = statusText; this.headers = headers; if (data) this.data = data; } }