Repository navigation
refactor: one error base class, one problem document, one table of network codes - #740
Merged
Merged
Conversation
…twork codes Every error class of the packages extends CodedError (pivotkit-core/internal), which holds code and details; each class keeps its name and members. REST problems and the download links' problems are built by problemDocument. guardedFetch's transient codes, a source's codes that may pass and the command line's words for a failed connection are one table, NETWORK_FAILURES in pivotkit-node/net. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…twork table Review follow-ups: CodedError takes the types of code and details as template parameters, so each class keeps the types it had (OperationError's details) and a class without codes says so; NETWORK_FAILURES' entries are frozen; tests for CodedError and problemDocument; net.js header and changelogs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Step 4 of the layering rework: one error base class, one problem-document builder, and one table of network codes.
What changed
CodedErroris the base of every error class of the packages:PivotkitError,CliError(and soRemoteError),OperationError, and in pivotkit-serverAuthRefusal,CommandError,SecretError,OpenApiError,SignedTokenError,AnswerShapeError,SourceError,SecretFileError,UploadFailure,ConfigErrorandGuardedFetchError.packages/pivotkit-core/src/errors.jsand is exported only frompivotkit-core/internal, so it is not public API.codeanddetails, and sets each only when it is given. A class adds only its own members and itsname.codeanddetailsper class (@extends {CodedError<C, D>}). The public types stay as they were:PivotkitError.codeisPivotkitErrorCode,OperationError.detailsisOperationErrorDetails | undefined,CliError.codeisstring.AuthRefusal,OpenApiError,AnswerShapeError). They takeundefinedfor it, and still have nocodemember.problemDocumentinrest/problem.jsis the one shape of an RFC 9457 problem:type,title,status,code,detail, then further members.problem()(REST) and the download links' answers (downloads.jsanswerOf) build it there.typeOfis no longer exported, since onlyproblemDocumentuses it.problemOfwas already the one mapping from an error to a problem.NETWORK_FAILURESinpivotkit-node/netis the one table of a failed connection's codes, as you asked. It replaces:TRANSIENTinsources/fetch.js, now the columnretryNETWORK_CODESinsources/run.js, now the columnpassesNETWORK_TEXTSin the CLI'sremote.js, now the columntextBehaviour: no change
test/errors.test.jspins them. The one difference is the enumeration order of own keys:codenow comes first. Nothing in the code or tests reads that order, so it would show only in a consumer'sJSON.stringify(error)or a crash printout.test/net.test.jspins the sets. The CLI's words are byte-identical; I compared them by script.retryincludes EPIPE, EHOSTUNREACH, ENETUNREACH and ECONNABORTED.passesincludes undici's three timeouts.Release note
CodedErrorfrompivotkit-core/internal. A published pivotkit-core 0.9.0 does not have it, so the release must raise theirpivotkit-coreranges to the new core.tests/ci.test.jsalready asks for that when core's version moves.Not part of this change (say what does not fit)
{ code, requestId }problem, not a full document. That was so before, and the code now says so in a comment.sign-in.jskeeps its ownTRANSIENTset. It lists the CLI'sRemoteErrorcodes, not network codes.Growth (scripts/growth.js measures, before → after)
No baseline entry changed.
Checks
npm run lint,npm run types,npm test(all workspaces andtests/),npm run growth,npm run pack:check: green locally.npm test..d.ts. Its findings are fixed:OperationError.detailstyped and give the classes without codes an honest typeCodedErrorandproblemDocumentPlaces checked for docs:
docs/reference/service-exports.mdneeds no change, because nothing public was added or removed.🤖 Generated with Claude Code