AbsoluteJS

Eden

@absolutejs/edenv0.2.0betaDev Tools

Unwraps Eden Treaty failures into real Errors that keep the HTTP status, so 402, 409 and 500 stay distinguishable.

Tiny error helpers for Eden Treaty clients. Eden surfaces a failed call as { status, value }, and most call sites throw error.value — dropping the HTTP status so a 402 paywall, a 409 conflict and a 500 all look the same downstream. These helpers normalize any thrown value into a real Error that keeps .status, so error handling stays status-aware across the Elysia + Eden stack. Zero dependencies; works in the browser and on the server.

#Installation

BASH
bun add @absolutejs/eden

#Capabilities

Overview

Tiny error helpers for Eden Treaty clients. Eden surfaces a failed call as { status, value } — and most call sites throw error.value, dropping the HTTP status so a 402 paywall, a 409 conflict, and a 500 all look the same downstream. This fixes that.

API

apiError(error, fallback?) — normalize any thrown value (or an Eden

{ status, value }) into an Error that keeps .status.

apiErrorMessage(error, fallback?) — best-effort human message.

Show 2 more

apiErrorStatus(error) — the HTTP status carried by an error, if any.

isPaywallError(error) — true for a 402 Payment Required.

Pagination

List endpoints can share one bounded request/response contract without hiding their concrete database query:

CursorPage<T> is the corresponding envelope for stable keyset pagination. getPageCount, clampPageIndex, and getPageRange keep client pagination math consistent with the server contract.

Zero dependencies; works in the browser and on the server.

Show 1 more

Apache-2.0

Status-preserving errors

apiError(error, fallback?) normalizes any thrown value — or an Eden { status, value } — into an Error that keeps .status.

Human messages

apiErrorMessage(error, fallback?) extracts a best-effort human-readable message from whatever was thrown.

Status extraction

apiErrorStatus(error) returns the HTTP status carried by an error, if any, so handlers can branch on 402 vs 409 vs 500.

Paywall detection

isPaywallError(error) is true for a 402 Payment Required, making upgrade nudges a one-line check.

Zero dependencies

No dependencies and no runtime assumptions — the same helpers run in the browser and on the server.

Outcomes

What you can build

Overview

Tiny error helpers for Eden Treaty clients. Eden surfaces a failed call as { status, value } — and most call sites throw error.value, dropping the HTTP status so a 402 paywall, a 409 conflict, and a 500 all look the same downstream. This fixes that.

API

apiError(error, fallback?) — normalize any thrown value (or an Eden

Pagination

List endpoints can share one bounded request/response contract without hiding their concrete database query:

Hardening checklist

Production guidance

Make every external boundary explicitPin the deployed @absolutejs/eden version, replace example or memory-backed dependencies with durable implementations, bound external calls, protect credentials, and emit enough evidence to retry or recover safely.

Follow in order

Troubleshooting path

1
Overview
Tiny error helpers for Eden Treaty clients. Eden surfaces a failed call as { status, value } — and most call sites throw error.value, dropping the HTTP status so a 402 paywall, a 409 conflict, and a 500 all look the same downstream. This fixes that.
2
API
apiError(error, fallback?) — normalize any thrown value (or an Eden

#@absolutejs/eden quick start

Partial snippet

# @absolutejs/eden

TS
import { apiError, isPaywallError } from "@absolutejs/eden";

const { data, error } = await api.things.get();
if (error) throw apiError(error); // a real Error that KEEPS error.status

// elsewhere
try {
  await loadPremiumPanel();
} catch (e) {
  if (isPaywallError(e)) showUpgradeNudge();
  else showError(apiErrorMessage(e));
}

#Pagination

Partial snippet

List endpoints can share one bounded request/response contract without hiding their concrete database query:

TS
import {
  normalizeOffsetPage,
  type OffsetPage,
} from "@absolutejs/eden";

const { limit, offset } = normalizeOffsetPage(request, {
  defaultLimit: 25,
  maxLimit: 100,
});

const response: OffsetPage<User> = { data: rows, total };

#Quick Start

Partial snippet

Throw a status-preserving Error at the call site, then branch on the status wherever the error surfaces.

TS
import {
	apiError,
	apiErrorMessage,
	isPaywallError
} from '@absolutejs/eden';

const { data, error } = await api.things.get();
if (error) throw apiError(error); // a real Error that KEEPS error.status

// elsewhere
try {
	await loadPremiumPanel();
} catch (e) {
	if (isPaywallError(e)) showUpgradeNudge();
	else showError(apiErrorMessage(e));
}
Made for Eden Treaty
Pairs with any Eden Treaty client — including the type-safe treaty clients AbsoluteJS apps generate from their Elysia server type — so end-to-end type safety extends to the failure path.

Current package surface

What ships today

@absolutejs/edenv0.2.0 · betaData & SyncnpmSource