UMANTHIR

JavaScript / TypeScript

Errors

Every error thrown by the SDK extends UmanthirError. Errors from the API extend APIError, which carries status, apiMessage (the API's error.message), method, url, headers, body, retryAfter (seconds) and apiVersion.

ClassWhen
ValidationErrorAn argument was rejected before sending the request (bad name, page, level, ...).
ConnectionErrorThe API could not be reached (DNS, TLS, connection reset, offline).
TimeoutErrorAn attempt took longer than timeout (extends ConnectionError).
AbortErrorThe request was cancelled through your signal.
BadRequestError400: the API rejected an argument (Unknown vocation., Invalid page., ...).
NotFoundError404: character, guild, world, house, item or route not found.
RateLimitError429: rate limit exceeded; rateLimit holds { limit, remaining, reset }.
UpstreamError502 or 520: the API could not read tibia.com.
ServiceUnavailableError503; reason is "maintenance", "busy", "wiki_unavailable" or "unknown".
APIErrorAny other error status.
ts
import { RateLimitError, ServiceUnavailableError } from "@umanthir/sdk";

try {
  await client.guilds.get("Alanui Institute");
} catch (error) {
  if (error instanceof RateLimitError) console.log(`Try again in ${error.retryAfter} s`);
  else if (error instanceof ServiceUnavailableError && error.reason === "maintenance") {
    console.log("tibia.com is under maintenance");
  } else throw error;
}

In the browser bundle the classes are available on the global: Umanthir.NotFoundError, Umanthir.RateLimitError, and so on.

Next: Warnings.

Cookies

Session, language and theme use necessary cookies and stay on. Usage tagging, such as visit analytics or advertising, starts only if you allow it.

Manage cookies

Session, language and theme use necessary cookies and stay on. Usage tagging, such as visit analytics or advertising, starts only if you allow it.