Skip to content

NamedError hides data.message: Error.message is set to the tag name #31414

Description

@albertdbio

Description

NamedError — the base class for the serialized error union (ProviderAuthError, UnknownError, APIError, etc.) — sets Error.message to its own tag name. Its constructor calls super(name), so every instance ends up with Error.message === Error.name.

Because Cause.pretty and Error.prototype.toString() render an error as ${name}: ${message}, this comes out as ProviderAuthError: ProviderAuthError, and the real data.message is never shown.

Steps to reproduce

  1. Construct any NamedError, e.g. new ProviderAuthError({ providerID, message: "invalid token" }).
  2. Render it via Cause.pretty(Cause.fail(err)) or err.toString().
  3. Observe "ProviderAuthError: ProviderAuthError" — the "invalid token" detail is hidden.

OpenCode version

dev (current)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions