errors

A guide to handling errors in the QAuth authentication server. It defines shared error types, a consistent JSON response format, and rules for keeping passwords, tokens, secrets, and internal paths out of responses.

In plain words
What is it for?
Use it when throwing or handling errors, writing the global error handler, or reviewing authentication-server error responses.
Why use it?
It prevents each route from inventing its own error behavior and reduces the risk of revealing sensitive information.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/qauth-labs/qauth/errors
Any agent
npx skills add qauth-labs/qauth --skill errors
Clone the repo
git clone --depth 1 https://github.com/qauth-labs/qauth

Made for: Claude Code, Codex.

Per session 59 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 734 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00059 $0.00734
Opus 5 $0.00030 $0.00367
Sonnet 5 $0.00012 $0.00147
Haiku 4.5 $0.00006 $0.00073

Measured 2d ago against content hash 449d8cd58c28, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

errors scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/errors/SKILL.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Error Handling (QAuth)

Standards-aligned error handling for the QAuth auth-server. Throw domain errors, return a consistent JSON shape, and never leak sensitive data. Use this skill when raising/handling errors or reviewing error-handling code.

Use Domain Errors

Throw domain-specific errors from @qauth-labs/shared-errors:

// ✅ GOOD: Domain error with statusCode
import { NotFoundError, InvalidCredentialsError } from '@qauth-labs/shared-errors';

if (!user) {
  throw new NotFoundError('User', userId);
}

if (!passwordValid) {
  throw new InvalidCredentialsError(); // Generic message prevents enumeration
}

// ❌ BAD: Generic Error or ad-hoc status codes
throw new Error('User not found');
reply.code(404).send({ error: 'Not found' });

Error Response Shape

All errors return consistent JSON (handled by the global error handler):

  • Required: error (string), statusCode (number)
  • Optional: code (e.g. INVALID_CREDENTIALS), feedback (password rules), constraint (DB constraint), retryAfter (429), details (validation errors)

Security

  • No sensitive data: Never expose passwords, tokens, secrets, or internal paths in error messages.
  • Generic auth errors: Use InvalidCredentialsError with the same message for "user not found" and "wrong password" to prevent user enumeration.
  • Stack traces: Only in development (NODE_ENV !== 'production'); never in production responses.
  • Logging: Log full error details server-side; sanitize client responses.

See the security skill for timing-safe comparison and minimum-response-time rules that complement generic error messages.

Error Class Pattern

export class NotFoundError extends Error {
  readonly statusCode = 404;

  constructor(entity: string, id: string) {
    super(`${entity} with id ${id} not found`);
    this.name = 'NotFoundError';
    Object.setPrototypeOf(this, NotFoundError.prototype);
    if (Error.captureStackTrace) {
      Error.captureStackTrace(this, NotFoundError);
    }
  }
}

Read the full file on GitHub · 94 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 94 lines · 59 tokens per session scan A 449d8cd58c28

Subscribe to this mod's changes

errors is a skill published in the GitHub repository qauth-labs/qauth (24 stars, last pushed 6d ago), licensed Apache-2.0. It adds 59 tokens to every session and 734 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.