/tsed:tsed-exceptionsfrom Ts.ED
Handles errors and shapes responses in Ts.ED v8 apps using @tsed/exceptions, @tsed/platform-exceptions, and @tsed/platform-response-filter. Covers typed exceptions, custom JSON payloads, @Catch filters, 404 pages, response envelopes, and debugging.
Ships in Ts.ED. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Throw typed exceptions anywhere in the request flow. PlatformExceptions routes each error to one exception filter, which writes the response. Response filters shape successful responses only.
Package map (never import from @tsed/common):
| Symbol | Package |
|---|---|
Exception, BadRequest, Unauthorized, Forbidden, NotFound, Conflict, UnprocessableEntity, TooManyRequests, InternalServerError, ... | @tsed/exceptions |
Catch, ExceptionFilterMethods, ResourceNotFound, PlatformExceptions | @tsed/platform-exceptions |
ResponseFilter, ResponseFilterMethods | @tsed/platform-response-filter |
PlatformContext | @tsed/platform-http |
ValidationError, ParamValidationError | @tsed/platform-params |
import {BadRequest, NotFound} from "@tsed/exceptions";
throw new NotFound("Calendar not found");
throw new BadRequest("Invalid import file", cause); // cause: Error | string | object
const error = new BadRequest("Invalid payload");
error.errors = [{path: "/email", message: "already used"}];
error.setHeaders({"x-reason": "duplicate"});
throw error;
new Xxx(message, origin?). Base class: new Exception(status, message, origin?). error.name is derived from the status (NOT_FOUND, BAD_REQUEST); error.status holds the code.origin as Error or string is stored in error.origin and appended to the message as , innerException: <message>. origin as a plain object is stored in error.body.headers (via setHeader/setHeaders) are copied to the response; an errors array is copied to the payload. Both are also read from error.origin.response.status(...) manually in handlers. Do not throw strings or plain objects.import {Conflict} from "@tsed/exceptions";
export class EmailAlreadyUsed extends Conflict {
constructor(email: string) {
super(`Email ${email} is already used`);
this.errors = [{code: "EMAIL_ALREADY_USED", email}];
}
}
Extend the built-in class matching the status. Alternatively keep domain errors HTTP-free (plain Error subclasses) and translate them in an exception filter.
Any Exception subclass is sent with its status as application/json:
{"name": "NOT_FOUND", "message": "Calendar not found", "status": 404, "errors": []}
stack is added only when env is development. Any other Error is sent with error.status || error.statusCode || 500; in production its body is the string "InternalServerError", otherwise the same object shape.name: "AJV_VALIDATION_ERROR", a message starting with Bad request on parameter "request.body", and errors[] holding the AJV entries (keyword, dataPath, message, modelName, requestPath). A missing required parameter gives REQUIRED_VALIDATION_ERROR. Rules that produce them: tsed-models.ResourceNotFound (a NotFound with url), message Resource "<url>" not found.import {Exception} from "@tsed/exceptions";
import {Catch, type ExceptionFilterMethods} from "@tsed/platform-exceptions";
import type {PlatformContext} from "@tsed/platform-http";
@Catch(Exception)
export class HttpExceptionFilter implements ExceptionFilterMethods<Exception> {
catch(error: Exception, ctx: PlatformContext) {
ctx.logger.error({event: "HTTP_ERROR", status: error.status, message: error.message});
ctx.response
.setHeaders(error.headers)
.status(error.status)
.body({code: error.name, detail: error.message, errors: error.errors || []});
}
}
@Catch(...types) accepts classes or class-name strings (for third-party errors that cannot be imported, e.g. @Catch("MongooseError")).@Catch registers the class when the file is evaluated. Import the file from the server entry point (import "./filters/HttpExceptionFilter.js";) or list the class in imports. There is no configuration key for exception filters.Error filter. One filter handles one error.Error, Exception, Mongoose errors and thrown strings.catch must write the response: ctx.response.status(...).body(...). It may be async. Filters are injectable; use inject() or @Inject() for services.@Catch(EmailAlreadyUsed)), keep one generic @Catch(Exception) and, if needed, one @Catch(Error).error.stack or raw third-party messages in a custom @Catch(Error) filter.Custom 404:
import {Catch, type ExceptionFilterMethods, ResourceNotFound} from "@tsed/platform-exceptions";
import type {PlatformContext} from "@tsed/platform-http";
@Catch(ResourceNotFound)
export class ResourceNotFoundFilter implements ExceptionFilterMethods<ResourceNotFound> {
catch(error: ResourceNotFound, ctx: PlatformContext) {
ctx.response.status(404).body({status: 404, message: error.message, url: error.url});
}
}
import type {Context} from "@tsed/platform-params";
import {ResponseFilter, type ResponseFilterMethods} from "@tsed/platform-response-filter";
@ResponseFilter("application/json")
export class EnvelopeFilter implements ResponseFilterMethods {
transform(data: unknown, ctx: Context) {
return {data, errors: [], links: []};
}
}
// Server.ts
@Configuration({responseFilters: [EnvelopeFilter]})
export class Server {}
responseFilters. Decorating and importing is not enough: unlisted filters are ignored."*/*" is the fallback for all types.@ContentType, @(Returns(200, Model).ContentType("text/xml")), or JSON for objects), negotiated against the request Accept header when present.@Returns schemas to describe the envelope (generic wrapper model: tsed-models, tsed-openapi).@Get("/:id")
@Returns(200, Calendar)
@(Returns(404, NotFound).Description("Calendar not found"))
get(@PathParams("id") id: string) {}
Built-in exception classes ship with a schema (name, message, status, errors, stack). If a custom filter changes the payload, pass a model describing the new shape instead.
InternalServerError for an expected error: a plain Error was thrown instead of an Exception subclass.responseFilters, or the negotiated content type differs from the filter's., innerException: ...: an Error or string was passed as second constructor argument. Pass details through errors instead.ResourceNotFound imported from @tsed/platform-http (as older doc snippets show) fails; import it from @tsed/platform-exceptions.ctx.response.body(...), or also rethrew.@tsed/exceptions classes or subclasses; nothing throws strings.@Catch, implement catch(error, ctx), and are imported at startup.responseFilters.@Returns.@tsed/common import; relative imports end with .js.Depth: https://tsed.dev/docs/exceptions.md, https://tsed.dev/docs/response-filter.md, https://tsed.dev/docs/not-found-page.md.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub tsedio/tsed --plugin tsed13 skills in this plugin
/tsed-cliScaffolds Ts.ED v8 projects and generates files with the Ts.ED CLI v7, through its MCP server (tools set-workspace, init-project, list-templates, get-template, generate-file) or the tsed binary (tsed init, generate, template, add, run, update, dev, build). Use when creating a Ts.ED project, adding a controller, service, middleware, model, interceptor, pipe, decorator or custom template, when package.json has a "tsed" key or @tsed/cli, when a .templates/ directory exists, or on errors E_CWD_NOT_SET, E_PROJECT_NOT_INITIALIZED, E_TEMPLATE_UNKNOWN, E_ARGS_INVALID./tsed-configurationConfigure and bootstrap a Ts.ED v8 server - the @Configuration decorator or configuration() on the Server class, PlatformExpress/PlatformKoa/PlatformFastify.bootstrap, server options (mount, middlewares, httpPort, httpsPort, acceptMimes, logger, statics, views, responseFilters, imports), per-platform express/koa/fastify options, and @tsed/config sources (envs, dotenv, json, yaml). Use when editing Server.ts, index.ts or src/config, adding @tsed/config or the extends option, or reading settings with constant(), refValue(), @Constant, @Value or configuration().get()./tsed-controllersWrite Ts.ED v8 HTTP controllers and routes - @Controller paths and nested children, mounting through the `mount` configuration, verb decorators from @tsed/schema, parameter decorators from @tsed/platform-params, typed inputs, response decorators and custom endpoint decorators. Use when adding or fixing a REST endpoint, when a route returns 404 or is shadowed by another route, when @BodyParams/@QueryParams/@PathParams receive a plain object or the wrong type, or when working with @Returns, @Status, @Redirect, @View, @Hidden, @Req/@Res or useDecorators./tsed-diDeclare, inject and scope Ts.ED v8 providers and wire lifecycle hooks - @Injectable, @Module, @Controller, @Inject, the functional API (inject, injectMany, lazyInject, constant, refValue, injectable().factory/asyncFactory/class/value, injector, context, logger), ProviderScope, custom tokens, @tsed/hooks ($on, $emit, $asyncEmit, $alter) and request context. Use when writing services or modules with @tsed/di, fixing InjectionError, "Given token is undefined" or undefined injected properties, choosing a scope, adding $onInit/$onDestroy/$onReady, or replacing registerProvider and other deprecated DI APIs./tsed-docsLocates authoritative Ts.ED v8 documentation and API reference instead of guessing framework APIs. Routes a topic to the right tsed.dev page, its markdown twin, the llms.txt indexes (tsed.dev, cli.tsed.dev, logger.tsed.dev) and the sibling tsed-* skills. Use when working in a project that depends on @tsed/* packages and an import path, decorator (@Controller, @Injectable, @Returns), function (inject, injectable, configuration), option name or error message is uncertain, when an example imports from @tsed/common, or before answering any "how do I ... in Ts.ED" question./tsed-loggerConfigure and use logging in a Ts.ED v8 application with @tsed/logger v8. Covers logger injection, request-scoped logs with $ctx.logger, the `logger` configuration key, @tsed/platform-log-request, appenders, layouts, JSON logs in production, connectors and custom appenders. Use when working with $log, inject(Logger), logger(), ContextLogger, $log.appenders.set, @Appender, @Layout or any @tsed/logger-* package, or when seeing "Appender ... doesn't exists", "Missing ... layout doesn't exists", duplicated log lines, missing request logs after a v8 upgrade, or an appender ignoring its levels.Other plugins' skills for the same job