variable ErrorCodes

Standard error codes for common Nagare errors

Use these codes for consistent error handling across the codebase. Each error code represents a specific failure scenario that users may encounter.

Error Code Categories:

  • GIT_NOT_INITIALIZED: Working directory is not a git repository
  • GIT_UNCOMMITTED_CHANGES: Uncommitted changes prevent release
  • GIT_USER_NOT_CONFIGURED: Git user.name or user.email not set
  • GIT_NO_COMMITS: No commits in repository
  • GIT_TAG_EXISTS: Tag already exists for version
  • GIT_REMOTE_ERROR: Error communicating with remote repository

Configuration errors (CONFIG_*)

  • CONFIG_NOT_FOUND: No nagare.config.ts file found
  • CONFIG_INVALID: Configuration file has validation errors
  • CONFIG_MISSING_REQUIRED: Required configuration fields missing

Version errors (VERSION_*)

  • VERSION_NOT_FOUND: Version pattern not found in file
  • VERSION_INVALID_FORMAT: Version doesn't match semver format
  • VERSION_FILE_NOT_FOUND: Specified version file doesn't exist
  • VERSION_BUMP_INVALID: Invalid bump type specified

File operation errors (FILE_*)

  • FILE_NOT_FOUND: Specified file doesn't exist
  • FILE_UPDATE_FAILED: Failed to update file contents
  • FILE_PATTERN_NO_MATCH: Update pattern didn't match
  • FILE_HANDLER_NOT_FOUND: No handler for file type
  • FILE_JSON_INVALID: JSON file has syntax errors

GitHub integration errors (GITHUB_*)

  • GITHUB_CLI_NOT_FOUND: GitHub CLI (gh) not installed
  • GITHUB_AUTH_FAILED: GitHub authentication failed
  • GITHUB_RELEASE_FAILED: Failed to create GitHub release

Template errors (TEMPLATE_*)

  • TEMPLATE_INVALID: Template syntax error
  • TEMPLATE_PROCESSING_FAILED: Template rendering failed
  • TEMPLATE_SECURITY_VIOLATION: Template contains unsafe code

Security errors (SECURITY_*)

  • SECURITY_INVALID_GIT_REF: Invalid git reference format
  • SECURITY_EMPTY_GIT_REF: Empty git reference provided
  • SECURITY_INVALID_GIT_REF_CHARS: Git reference contains forbidden characters
  • SECURITY_INVALID_GIT_REF_PATTERN: Git reference has invalid pattern
  • SECURITY_GIT_TAG_TOO_LONG: Git tag exceeds maximum length
  • SECURITY_INVALID_COMMIT_HASH: Invalid git commit hash format
  • SECURITY_INVALID_FILE_PATH: Invalid file path format
  • SECURITY_PATH_TRAVERSAL: Directory traversal attempt detected
  • SECURITY_PATH_ESCAPE: Path escapes base directory
  • SECURITY_INVALID_VERSION: Invalid version string
  • SECURITY_INVALID_SEMVER_FORMAT: Version doesn't match semver format
  • SECURITY_INVALID_CLI_ARG_TYPE: CLI argument has wrong type
  • SECURITY_SHELL_INJECTION: Shell metacharacters detected
  • SECURITY_NULL_BYTE_INJECTION: Null byte injection attempt

General errors

  • DEPENDENCY_NOT_FOUND: Required dependency missing
  • PERMISSION_DENIED: Insufficient permissions
  • OPERATION_CANCELLED: User cancelled operation
  • UNKNOWN_ERROR: Unexpected error occurred

Examples

Example 1

import { ErrorCodes, NagareError } from "@rick/nagare";

throw new NagareError(
  "Git repository not initialized",
  ErrorCodes.GIT_NOT_INITIALIZED,
  ["Run 'git init' to initialize repository"]
);

Properties