Repository navigation
0.1.0-rc.2: statusErrors, onExit plugin hook, consoleLogger - #6
Merged
Merged
Conversation
- Map statuses to error schemas on the client, endpoints, definitions and single calls, tried call → endpoint → client - Add `client.statusErrors` and `statusErrors` on endpoints and definitions, plus `StatusErrorMap`, `StatusError`, `StatusErrorSchema` and `StatusErrorServices` - Add `examples/status-errors.ts` and wire the feature into `examples/app`, with README, CHANGELOG, tests and smoke checks
- Add an `onExit(exit, ctx)` plugin hook that runs once per call with its `Exit`, response and duration, and a `RExit` type parameter for its services - Add `consoleLogger` to `@monarcode/effetch/plugins`: per-call console groups with headers, bodies and errors, redaction, colors, filters and per-call options - Document both in the README and CHANGELOG, update `examples/builtins.ts`, and add tests and smoke checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Release candidate
0.1.0-rc.2. It adds two features: typed errors chosen by response status (statusErrors), and anonExitplugin hook with a built-inconsoleLoggerplugin.statusErrors: typed errors by statusError responses can now be decoded into your own error types, chosen by status, instead of arriving as a generic
HttpError.make), an endpoint, or a single call. For a given status, the call's schemas are tried first, then the endpoint's, then the client's.[UnknownUser, AlreadyAssigned]is tried in order, so literal fields likecodecan tell apart responses that share a status. A body that no schema decodes falls through toHttpError,defaultErrorand plugins as before._taghandling: backends don't send a_tag, so effetch adds the schema's literal_tagto the body before decoding. PlainSchema.TaggedErrorclasses work as they are.Schema.encodeKeyshandles field renames.catchTagandcatchTagswork on them.NoInfer, so generic wrappers still infer correctly.StatusErrorMap,StatusError,StatusErrorSchema,StatusErrorServices.client.statusErrors,Endpoint.statusErrors.Plugin
onExithook andconsoleLoggeronExit(exit, ctx): a new plugin hook that runs once per call with the call'sExit, the response (when there is one) and the duration. Its services are tracked by a newRExittype parameter onPlugin.Definition.consoleLogger: a new plugin in@monarcode/effetch/pluginsthat prints each call as a console group with headers, bodies and errors. It supports:Docs and examples
examples/status-errors.ts.examples/builtins.tsandexamples/app/*are updated.Testing
pnpm run checkpasses. It covers lint, format, typecheck, the docs check (65 exports), 496 tests including type tests, build, publint, attw, and the tarball smoke and editor checks.test/statusErrors.test.ts,test/types/statusErrors.test-d.ts, and theconsoleLoggertests.