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';
const AppError = error({ name: 'AppError' });
try {
processData(input);
} catch (err) {
raise(AppError().addNote('Processing failed at line 42'));
}
// Multiple notes supported
raise(
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)
Feature Description
Implement the
.addNote()method on theErrorInstancetype. This method enriches errors with additional context notes, inspired by Python 3.11'sadd_note()functionality.Problem It Solves
Proposed Solution
Alternatives Considered
withContext()(deferred to v2.0.0)