Skip to content

[Feature]: Add .addNote() method to ErrorInstance #9

Description

@martyy-code

Feature Description

Implement the .addNote() method on the ErrorInstance type. This method enriches errors with additional context notes, inspired by Python 3.11's add_note() functionality.

Problem It Solves

  • Errors often need additional context discovered at runtime
  • Notes provide better debugging information without changing the core API
  • Enables rich error enrichment after catching

Proposed Solution

import{error,raise}from'@deessejs/errors';constAppError=error({name: 'AppError'});try{processData(input);}catch(err){raise(AppError().addNote('Processing failed at line 42'));}// Multiple notes supportedraise(AppError().addNote('Attempt 1 failed').addNote('Retrying...').addNote('Attempt 2 failed'));

Alternatives Considered

  • Type guards approach (deferred to v1.2.0)
  • Context injection via withContext() (deferred to v2.0.0)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions