Blyp Docs

Errors

Blyp error handling revolves around three pieces:

Choose the right entry point

NeedUse
Create a brand-new structured application errorcreateError()
Normalize a failed fetch() response or foreign payloadparseError()
Reuse a status preset or define a shared domain errorHTTP_CODES

Shared error shape

A BlypError can carry more than a message:

That makes the same error useful for runtime logging, API responses, and operator-facing debugging.

Typical flow

  1. Build a first-party failure with createError() or normalize an external one with parseError().
  2. Throw or return the resulting BlypError.
  3. Reuse HTTP_CODES when the same pattern appears across multiple handlers or services.

What a BlypError looks like end to end

Code:

throw createError({
  status: 402,
  message: "Payment failed",
});

What Blyp logs:

[ERROR] Payment failed
  status=402 type=BlypError

HTTP response body:

{
  "status": 402,
  "message": "Payment failed"
}

parseError() output

const parsed = parseError(err);

Result shape:

{
  "status": 500,
  "message": "Unexpected token in JSON",
  "type": "SyntaxError",
  "stack": "SyntaxError: Unexpected token...\\n    at JSON.parse (<anonymous>)"
}