class NagareError
extends Error

Enhanced error class for Nagare with actionable suggestions

Provides structured error messages with:

  • Clear error description
  • Actionable suggestions for resolution
  • Contextual information
  • Error codes for programmatic handling

Examples

Example 1

throw new NagareError(
  "Configuration file not found",
  "CONFIG_NOT_FOUND",
  [
    "Run 'nagare init' to create a configuration",
    "Create nagare.config.ts manually",
    "Specify config path: --config ./path/to/config.ts"
  ],
  { searchedPaths: ["./nagare.config.ts", "./nagare.config.js"] }
);

Constructors

new
NagareError(
message: string,
code: string,
suggestions?: string[],
context?: Record<string, unknown>,
docsUrl?: string,
)

Create an enhanced error (backward compatible string version)

new
NagareError(
messageKey: TranslationKey,
code: string,
options?: ErrorOptions,
)

Create an enhanced error with i18n support

new
NagareError(
messageOrKey: string | TranslationKey,
code: string,
suggestionsOrOptions?: string[] | ErrorOptions,
context?: Record<string, unknown>,
docsUrl?: string,
)

Properties

readonly
abstract
context: Record<string, unknown>
readonly
abstract
docsUrl: string
readonly
abstract
suggestions: string[]

Methods

toJSON(): Record<string, unknown>

Create a JSON representation for logging

toString(): string

Format error for CLI output with colors and structure

See