Skip to content

dx: add consistent error messages with error codes to storage engine functions #70

@George-iam

Description

@George-iam

The storage engine (src/storage/engine.ts) functions like atomicWrite, appendLine, and writeJson catch and re-throw errors, but the error messages do not include the file path that failed or a consistent error code prefix. When a storage operation fails deep in the call stack, the error message should make it immediately clear which file and which operation failed. Add an AXME_STORAGE prefix and include the file path in all re-thrown errors.

Relevant files:

  • src/storage/engine.ts — wrap caught errors with contextual messages

Example improvement:

// Before:
throw err;

// After:
throw new Error(`AXME_STORAGE: atomicWrite failed for ${filePath}: ${(err as Error).message}`, { cause: err });

Acceptance criteria:

  • All functions that can throw (atomicWrite, appendLine, writeJson) include the file path and operation name in the error message
  • Error messages have a consistent AXME_STORAGE: prefix
  • Original error is preserved as cause
  • npm run lint and npm test pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    dxDeveloper experience improvementsgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions