{"id":47420,"library":"dom-exception-modern","title":"dom-exception-modern","description":"A zero-dependency migration helper for replacing the deprecated `domexception` package with the native `DOMException` constructor available in modern Node.js (>=18), browsers, and Deno. Version 0.1.0 released in 2025. It default-exports the native DOMException for drop-in compatibility, and provides typed utility functions: `createDOMException`, `isDOMException`, `toDOMException`, and legacy code constants via `domExceptionCodes`. Ships TypeScript declarations. Unlike the legacy `domexception`, this package has no runtime fallback and is intended only for environments where DOMException is natively available.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/iexitdev/dom-exception-modern","tags":["javascript","domexception","DOMException","web","error","typescript","migration","replacement","deprecated"],"install":[{"cmd":"npm install dom-exception-modern","lang":"bash","label":"npm"},{"cmd":"yarn add dom-exception-modern","lang":"bash","label":"yarn"},{"cmd":"pnpm add dom-exception-modern","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is the native DOMException constructor. Named import will fail.","wrong":"import { DOMException } from 'dom-exception-modern'","symbol":"default (DOMException)","correct":"import DOMException from 'dom-exception-modern'"},{"note":"Named export, works alongside default import.","wrong":"import DOMException, { isDOMException } from 'dom-exception-modern'","symbol":"isDOMException","correct":"import { isDOMException } from 'dom-exception-modern'"},{"note":"Named export, not default.","wrong":"import createDOMException from 'dom-exception-modern'","symbol":"createDOMException","correct":"import { createDOMException } from 'dom-exception-modern'"},{"note":"Named export providing legacy numeric code constants.","wrong":"import domExceptionCodes from 'dom-exception-modern'","symbol":"domExceptionCodes","correct":"import { domExceptionCodes } from 'dom-exception-modern'"}],"quickstart":{"code":"import DOMException, { createDOMException, isDOMException, toDOMException, domExceptionCodes } from 'dom-exception-modern';\n\n// Use as a drop-in replacement for the deprecated 'domexception'\nconst err1 = new DOMException('Custom error', 'NotFoundError');\nconsole.log(err1.name); // 'NotFoundError'\nconsole.log(err1.message); // 'Custom error'\n\n// Create with utility\nconst err2 = createDOMException('Operation aborted', 'AbortError');\nconsole.log(err2.code); // 20 (AbortError code from legacy mapping)\n\n// Check for DOMException\nconsole.log(isDOMException(err1)); // true\nconsole.log(isDOMException(new Error())); // false\n\n// Convert unknown errors\nconst converted = toDOMException('some string error', 'TypeError');\nconsole.log(converted instanceof DOMException); // true\n\n// Legacy code constants\nconsole.log(domExceptionCodes.ABORT_ERR); // 20","lang":"typescript","description":"Shows default and named imports, constructor usage, utility helpers, and legacy code constants."},"warnings":[{"fix":"Ensure runtime supports DOMException natively. Use polyfill or stick with legacy 'domexception' for Node <18.","message":"Native DOMException required: Node >=18, modern browsers, Deno. Older environments will throw ReferenceError.","severity":"breaking","affected_versions":"all"},{"fix":"Replace `import DOMException from 'dom-exception-modern'` with `const DOMException = globalThis.DOMException` or just use `DOMException` directly.","message":"This package is intended as a migration path; directly using native DOMException is preferred in new code.","severity":"deprecated","affected_versions":"all"},{"fix":"Always use `new DOMException(...)` to create instances.","message":"Default export is the native DOMException constructor, not a polyfill. It cannot be instantiated without `new`.","severity":"gotcha","affected_versions":"all"},{"fix":"Rely on error `name` instead of `code` for cross-platform compatibility.","message":"`domExceptionCodes` object contains legacy numeric codes like `ABORT_ERR: 20`, but these may not match all browser implementations exactly.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.1.0':31 '18':26 '2025':34 'avail':22,84 'browser':27 'code':57 'compat':46 'constant':58 'constructor':21 'createdomexcept':52 'declar':63 'default':37 'default-export':36 'deno':29 'depend':8 'deprec':14,93 'dom':2 'dom-exception-modern':1 'domexcept':15,20,41,67,81,86,87 'domexceptioncod':60 'drop':44 'drop-in':43 'environ':79 'error':89 'except':3 'export':38 'fallback':73 'function':51 'helper':10 'intend':76 'isdomexcept':53 'javascript':85 'legaci':56,66 'migrat':9,91 'modern':4,24 'nativ':19,40,83 'node.js':25 'packag':16,69 'provid':48 'releas':32 'replac':12,92 'runtim':72 'ship':61 'todomexcept':54 'type':49 'typescript':62,90 'unlik':64 'util':50 'version':30 'via':59 'web':88 'zero':7 'zero-depend':6","created_at":"2026-06-07T16:51:25.779800+00:00","updated_at":"2026-06-07T16:51:25.779800+00:00","problems":[{"fix":"Use `import DOMException from 'dom-exception-modern'` (default import) instead of `import { DOMException } from 'dom-exception-modern'`.","cause":"Attempting to import 'DOMException' as a named export instead of default import.","error":"SyntaxError: The requested module 'dom-exception-modern' does not provide an export named 'DOMException'"},{"fix":"Upgrade Node to >=18 or use a polyfill like `domexception` package.","cause":"Running in an environment (e.g., Node <18) where native DOMException is not available.","error":"ReferenceError: DOMException is not defined"},{"fix":"Use `new DOMException(...)` to instantiate.","cause":"Calling `DOMException(...)` without the `new` keyword.","error":"TypeError: Class constructor DOMException cannot be invoked without 'new'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/iexitdev/dom-exception-modern#readme","github":"https://github.com/iexitdev/dom-exception-modern","docs":null,"changelog":null,"pypi":null,"npm":"dom-exception-modern","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}