{"_id":"@aglabo/agla-error-core","_rev":"2-61acc80b9104fe1993708340e0ca1046","name":"@aglabo/agla-error-core","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@aglabo/agla-error-core","version":"0.1.0","author":{"name":"atsushifx","email":"https://github.com/atsushifx"},"license":"MIT","_id":"@aglabo/agla-error-core@0.1.0","maintainers":[{"name":"atsushifx","email":"atsushifx+npm@gmail.com"}],"dist":{"shasum":"51d58df666c2f85d552a2b93cd71814cc9ecb1c8","tarball":"https://registry.npmjs.org/@aglabo/agla-error-core/-/agla-error-core-0.1.0.tgz","fileCount":4,"integrity":"sha512-nLP5ErVpRJDJycUb6OUCeK5lXtiyaXfK8TiwFe98WGIB0sWWXig4FSDwVXVr/Vs341vW0IbrXv4thF1FyvbSvQ==","signatures":[{"sig":"MEYCIQDGeWgido9pFVapnbSx3QtFzn3UAm44M5XlrAHdZ/7poQIhAPtAAnwhchl9T+Gd3k3G6zw6Sounil18eLetoyC2Ogn3","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27015},"type":"module","types":"./module/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./module/index.d.ts","import":"./module/index.js"}},"gitHead":"c9da65b49d853e8a3de1d47117a7870e0d70181c","imports":{"#src":"./src","#tests":"./tests","#shared":"./shared"},"private":false,"scripts":{"lint":"pnpm exec eslint --config ./configs/eslint.config.js --cache --cache-location .cache/eslint-cache/esLintCache ","build":"pnpm exec tsup --config ./configs/tsup.config.ts","clean":"pnpm rimraf module .cache","test:ci":"pnpm exec vitest run --config ./configs/vitest.config.integration.ts","lint:bun":"pnpm exec eslint --config ./configs/eslint.config.bun.js --cache --cache-location .cache/eslint-cache/esLintCache-bun ","test:all":"concurrently \"pnpm run test:develop\" \"pnpm run test:functional\" \"pnpm run test:ci\" \"pnpm run test:e2e\" \"pnpm run test:runtime\" ","test:e2e":"pnpm exec vitest run --config ./configs/vitest.config.e2e.ts","lint:deno":"pnpm exec deno lint","lint:types":"pnpm exec eslint --config ./configs/eslint.config.typed.js --cache --cache-location .cache/eslint-cache/esLintCacheTypes","check:types":"tsc --noEmit --incremental","check:dprint":"dprint check","check:spells":"cspell --config .vscode/cspell.json --cache --cache-location .cache/cspell/cSpellCache","lint:secrets":"secretlint --secretlintrc ./configs/secretlint.config.yaml --secretlintignore .gitignore --maskSecrets **/*","sync:configs":"pnpm -w run sync:configs ","test:develop":"pnpm exec vitest run --config ./configs/vitest.config.unit.ts","test:runtime":"concurrently \"pnpm run test:runtime:node\" \"pnpm run test:runtime:deno\" \"pnpm run test:runtime:bun\" ","format:dprint":"dprint fmt","prepublishOnly":"pnpm exec tsup --config ./configs/tsup.config.ts","test:functional":"pnpm exec vitest run --config ./configs/vitest.config.functional.ts","test:runtime:bun":"bun test ./src/__tests__/runtime/bun/","test:coverage:all":"concurrently \"pnpm run test:coverage:unit\" \"pnpm run test:coverage:functional\" \"pnpm run test:coverage:integration\" \"pnpm run test:coverage:e2e\" \"pnpm run test:coverage:runtime\"","test:coverage:e2e":"pnpm exec vitest run --coverage --config ./configs/vitest.config.e2e.ts","test:runtime:deno":"deno test src/**/__tests__/runtime/deno/*.spec.ts","test:runtime:node":"pnpm exec vitest run --config ./configs/vitest.config.runtime.ts ","test:coverage:unit":"pnpm exec vitest run --coverage --config ./configs/vitest.config.unit.ts","test:coverage:runtime":"pnpm exec vitest run --coverage --config ./configs/vitest.config.runtime.ts","test:coverage:functional":"pnpm exec vitest run --coverage --config ./configs/vitest.config.functional.ts","test:coverage:integration":"pnpm exec vitest run --coverage --config ./configs/vitest.config.integration.ts"},"_npmUser":{"name":"atsushifx","email":"atsushifx+npm@gmail.com"},"_npmVersion":"11.6.4","description":"Standardized error handling core module for @aglabo ecosystem with AglaError class, ErrorSeverity enum, and cross-runtime support","directories":{},"sideEffects":false,"_nodeVersion":"22.21.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/agla-error-core_0.1.0_1765288110874_0.231372535573674","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aglabo/agla-error-core","description":"Standardized error handling core module for @aglabo ecosystem with AglaError class, ErrorSeverity enum, and cross-runtime support","version":"0.1.1","private":false,"author":{"name":"atsushifx","email":"https://github.com/atsushifx"},"license":"MIT","type":"module","types":"./module/index.d.ts","imports":{"#src":"./src","#shared":"./shared","#tests":"./tests"},"exports":{".":{"types":"./module/index.d.ts","import":"./module/index.js"}},"sideEffects":false,"engines":{"node":">=20"},"dependencies":{},"devDependencies":{},"scripts":{"build":"pnpm exec tsup --config ./configs/tsup.config.ts","clean":"pnpm rimraf dist module .cache","format:dprint":"dprint fmt","check:dprint":"dprint check","check:types":"tsc --noEmit --incremental","check:spells":"cspell --config .vscode/cspell.json --cache --cache-location .cache/cspell/cSpellCache","lint":"pnpm exec eslint --config ./configs/eslint.config.js --cache --cache-location .cache/eslint-cache/esLintCache ","lint:types":"pnpm exec eslint --config ./configs/eslint.config.typed.js --cache --cache-location .cache/eslint-cache/esLintCacheTypes","lint:deno":"pnpm exec deno lint","lint:bun":"pnpm exec eslint --config ./configs/eslint.config.bun.js --cache --cache-location .cache/eslint-cache/esLintCache-bun ","lint:secrets":"secretlint --secretlintrc ./configs/secretlint.config.yaml --secretlintignore .gitignore --maskSecrets **/*","test:all":"concurrently \"pnpm run test:develop\" \"pnpm run test:functional\" \"pnpm run test:ci\" \"pnpm run test:e2e\" \"pnpm run test:runtime\" ","test:develop":"pnpm exec vitest run --config ./configs/vitest.config.unit.ts","test:functional":"pnpm exec vitest run --config ./configs/vitest.config.functional.ts","test:ci":"pnpm exec vitest run --config ./configs/vitest.config.integration.ts","test:e2e":"pnpm exec vitest run --config ./configs/vitest.config.e2e.ts","test:runtime":"concurrently \"pnpm run test:runtime:node\" \"pnpm run test:runtime:deno\" \"pnpm run test:runtime:bun\" ","test:runtime:node":"pnpm exec vitest run --config ./configs/vitest.config.runtime.ts ","test:runtime:deno":"deno test src/**/__tests__/runtime/deno/*.spec.ts","test:runtime:bun":"bun test ./src/__tests__/runtime/bun/","test:coverage:unit":"pnpm exec vitest run --coverage --config ./configs/vitest.config.unit.ts","test:coverage:functional":"pnpm exec vitest run --coverage --config ./configs/vitest.config.functional.ts","test:coverage:integration":"pnpm exec vitest run --coverage --config ./configs/vitest.config.integration.ts","test:coverage:e2e":"pnpm exec vitest run --coverage --config ./configs/vitest.config.e2e.ts","test:coverage:runtime":"pnpm exec vitest run --coverage --config ./configs/vitest.config.runtime.ts","test:coverage:all":"concurrently \"pnpm run test:coverage:unit\" \"pnpm run test:coverage:functional\" \"pnpm run test:coverage:integration\" \"pnpm run test:coverage:e2e\" \"pnpm run test:coverage:runtime\"","sync:configs":"pnpm -w run sync:configs "},"_id":"@aglabo/agla-error-core@0.1.1","_integrity":"sha512-rEVEKsPwI9O+Cc3JGFtIVJyyHjSXr6huQv7vaDDtgp5VUgPT/m7rGt/w6vNbUV+gRHp3dc98SOuczlPeAVxBLQ==","_resolved":"W:\\Temp\\d8c33f5d5e508bd3dbfcf8358ed7389e\\aglabo-agla-error-core-0.1.1.tgz","_from":"file:aglabo-agla-error-core-0.1.1.tgz","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-rEVEKsPwI9O+Cc3JGFtIVJyyHjSXr6huQv7vaDDtgp5VUgPT/m7rGt/w6vNbUV+gRHp3dc98SOuczlPeAVxBLQ==","shasum":"b48e65ea5ace66f9ab78fca3114b3c65b075522b","tarball":"https://registry.npmjs.org/@aglabo/agla-error-core/-/agla-error-core-0.1.1.tgz","fileCount":8,"unpackedSize":42168,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHNAXlHQKPoJFGYHkn2jaFDJwVYXV6BrCTTqoGpFoy0/AiEAhs9g3A/tVD5V7u16RfTZgZoHrOobDJp6YdG+dgJw1A4="}]},"_npmUser":{"name":"atsushifx","email":"atsushifx+npm@gmail.com"},"directories":{},"maintainers":[{"name":"atsushifx","email":"atsushifx+npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agla-error-core_0.1.1_1765338016587_0.879179940404546"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-09T13:48:30.810Z","modified":"2025-12-10T03:40:16.949Z","0.1.0":"2025-12-09T13:48:31.019Z","0.1.1":"2025-12-10T03:40:16.730Z"},"author":{"name":"atsushifx","email":"https://github.com/atsushifx"},"license":"MIT","description":"Standardized error handling core module for @aglabo ecosystem with AglaError class, ErrorSeverity enum, and cross-runtime support","maintainers":[{"name":"atsushifx","email":"atsushifx+npm@gmail.com"}],"readme":"---\ntitle: agla-error-core\ndescription: Standardized error handling core module for @aglabo ecosystem\n---\n\nEnglish | [日本語](README.ja.md)\n\n## @aglabo/agla-error-core\n\nStandardized error handling core module for @aglabo ecosystem.\n\n`@aglabo/agla-error-core` is a library that provides structured error handling.\nIt enables unified error processing with error codes, severity levels, and context information.\n\n## Features\n\n- **Structured Error Handling** - Consistent error representation with `AglaError` class\n- **Severity Levels** - Four levels: `FATAL`, `ERROR`, `WARNING`, `INFO`\n- **Error Chaining** - Error chain using ES2022 `Error.cause`\n- **Cross-runtime Support** - Compatible with Node.js, Deno, and Bun\n- **TypeScript First** - Full type safety\n- **Zero Dependencies** - No external dependencies\n\n## Installation\n\n```bash\n# pnpm\npnpm add @aglabo/agla-error-core\n\n# npm\nnpm install @aglabo/agla-error-core\n\n# yarn\nyarn add @aglabo/agla-error-core\n\n# bun\nbun add @aglabo/agla-error-core\n\n# deno\nimport { AglaError } from \"jsr:@aglabo/agla-error-core\";\n```\n\n## Quick Start\n\n### Basic Usage\n\nSince AglaError is an abstract class, you need to define your own error class:\n\n```typescript\nimport { AG_ERROR_SEVERITY, AglaError } from '@aglabo/agla-error-core';\n\n// Define custom error class\nclass ValidationError extends AglaError {\n  constructor(message: string, context?: Record<string, unknown>) {\n    super('ValidationError', message, {\n      code: 'VALIDATION_FAILED',\n      severity: AG_ERROR_SEVERITY.ERROR,\n      context,\n    });\n  }\n}\n\n// Use the error\ntry {\n  throw new ValidationError('Invalid email format', {\n    field: 'email',\n    value: 'invalid-email',\n  });\n} catch (error) {\n  if (error instanceof ValidationError) {\n    console.error(error.toString());\n    // => ValidationError: Invalid email format {\"field\":\"email\",\"value\":\"invalid-email\"}\n\n    console.log(error.toJSON());\n    // => {\n    //   errorType: 'ValidationError',\n    //   message: 'Invalid email format',\n    //   code: 'VALIDATION_FAILED',\n    //   severity: 'error',\n    //   context: { field: 'email', value: 'invalid-email' }\n    // }\n  }\n}\n```\n\n### Using Error Severity\n\n```typescript\nimport { AG_ERROR_SEVERITY, AG_isValidErrorSeverity } from '@aglabo/agla-error-core';\n\nclass DatabaseError extends AglaError {\n  constructor(message: string, severity = AG_ERROR_SEVERITY.ERROR) {\n    super('DatabaseError', message, {\n      code: 'DB_ERROR',\n      severity,\n      timestamp: new Date(),\n    });\n  }\n}\n\n// Fatal error\nconst fatalError = new DatabaseError(\n  'Connection pool exhausted',\n  AG_ERROR_SEVERITY.FATAL,\n);\n\n// Warning level error\nconst warningError = new DatabaseError(\n  'Query slow response',\n  AG_ERROR_SEVERITY.WARNING,\n);\n\n// Validate severity\nif (AG_isValidErrorSeverity('error')) {\n  // valid\n}\n```\n\n### Error Chaining\n\n```typescript\nclass NetworkError extends AglaError {\n  constructor(message: string) {\n    super('NetworkError', message, {\n      code: 'NETWORK_ERROR',\n      severity: AG_ERROR_SEVERITY.ERROR,\n    });\n  }\n}\n\ntry {\n  // Low-level error\n  throw new Error('Connection timeout');\n} catch (lowLevelError) {\n  // Chain to high-level error\n  const networkError = new NetworkError('Failed to fetch data');\n  const chainedError = networkError.chain(lowLevelError as Error);\n\n  console.log(chainedError.cause); // => Error: Connection timeout\n}\n```\n\n## API Reference\n\n### `AglaError`\n\nAbstract base class for unified error handling.\n\n#### Constructor\n\n```typescript\nconstructor(\n  errorType: string,\n  message: string,\n  options?: AglaErrorOptions | AglaErrorContext\n)\n```\n\n#### Properties\n\n| Property  | Type                             | Description                   |\n| --------- | -------------------------------- | ----------------------------- |\n| errorType | `string`                         | Error type identifier         |\n| message   | `string`                         | Error message                 |\n| code      | `string \\| undefined`            | Error code                    |\n| severity  | `AGT_ErrorSeverity \\| undefined` | Severity level                |\n| timestamp | `Date \\| undefined`              | Error creation timestamp      |\n| context   | `AglaErrorContext \\| undefined`  | Error context information     |\n| cause     | `Error \\| undefined`             | Error cause (ES2022 standard) |\n\n#### Methods\n\n| Method              | Description                                |\n| ------------------- | ------------------------------------------ |\n| toString()          | Returns error as string format             |\n| toJSON()            | Returns error as JSON format               |\n| chain(cause: Error) | Creates error chain (returns new instance) |\n\n### `AG_ERROR_SEVERITY`\n\nError severity level definitions.\n\n```typescript\nconst AG_ERROR_SEVERITY = {\n  FATAL: 'fatal', // Critical failures requiring immediate attention\n  ERROR: 'error', // Runtime errors preventing normal operation\n  WARNING: 'warning', // Potential issues that should be investigated\n  INFO: 'info', // Informational messages for debugging\n} as const;\n```\n\n### `AG_isValidErrorSeverity(value: unknown): boolean`\n\nType guard function to validate if a value is a valid severity level.\n\n## Requirements\n\n- Node.js: >= 20.0.0\n- Deno: Latest version\n- Bun: Latest version\n- TypeScript: >= 5.9\n\n## License\n\nMIT License - See [LICENSE](./LICENSE) for details.\n\n## Contributing\n\nBug reports and feature requests are welcome at [Issues](https://github.com/aglabo/agla-error-core/issues).\n\nPull requests are also welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.\n\n## Links\n\n- [GitHub Repository](https://github.com/aglabo/agla-error-core)\n- [npm Package](https://www.npmjs.com/package/@aglabo/agla-error-core)\n- [Issue Tracker](https://github.com/aglabo/agla-error-core/issues)\n\n---\n\nCopyright (c) 2025 [atsushifx](https://github.com/atsushifx). Released under the MIT License.\n","readmeFilename":"README.md"}