{"id":13447842,"url":"https://github.com/aleksandr-oleynikov/uncaught","last_synced_at":"2025-03-22T01:31:28.172Z","repository":{"id":57385808,"uuid":"74001771","full_name":"aleksandr-oleynikov/uncaught","owner":"aleksandr-oleynikov","description":"Module for handle uncaught errors and promises rejections","archived":false,"fork":false,"pushed_at":"2018-06-26T12:44:23.000Z","size":19,"stargazers_count":68,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-11T23:15:43.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aleksandr-oleynikov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-17T07:31:12.000Z","updated_at":"2024-03-14T16:31:05.000Z","dependencies_parsed_at":"2022-08-29T13:50:43.853Z","dependency_job_id":null,"html_url":"https://github.com/aleksandr-oleynikov/uncaught","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-oleynikov%2Funcaught","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-oleynikov%2Funcaught/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-oleynikov%2Funcaught/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleksandr-oleynikov%2Funcaught/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleksandr-oleynikov","download_url":"https://codeload.github.com/aleksandr-oleynikov/uncaught/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244893456,"owners_count":20527597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:28.368Z","updated_at":"2025-03-22T01:31:27.930Z","avatar_url":"https://github.com/aleksandr-oleynikov.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# uncaught [![Build Status](https://travis-ci.org/aleksandr-oleynikov/uncaught.svg?branch=master)](https://travis-ci.org/aleksandr-oleynikov/uncaught) [![npm version](https://badge.fury.io/js/uncaught.svg)](https://badge.fury.io/js/uncaught)\n\n`uncaught` is the module, which allows you to handle all uncaught errors and promise rejections through only one listener.\n\n# How it works\n\n`uncaught` listens for global object errors and unhandled rejections events:\n\n- For browser these are [error](https://developer.mozilla.org/en-US/docs/Web/Events/error) and [unhandledrejection](https://developer.mozilla.org/en-US/docs/Web/Events/unhandledrejection).\n\n- And for Node.js these are [uncaughtException](https://nodejs.org/api/process.html#process_event_uncaughtexception) and [unhandledRejection](https://nodejs.org/api/process.html#process_event_unhandledrejection).\n\nAfter one of these events fires, the module transfers `error` (and also `event` for browser mode) object(s) to all registered listeners functions.\n \n# Browser support\n\n#### Global error\n\n- Google Chrome 30+\n- Edge (All versions)\n- Internet Explorer 11\n- Firefox 33+\n- Opera 41+\n- Safari 10+\n- Yandex.Browser 16+\n- Android 4.4+\n- iOS 10.0+\n\n#### Global unhandled rejection\n\n- Google Chrome 49+\n- Opera 41+\n- Yandex.Browser 16+\n\n# Node.js support\n\n- Event `uncaughtException` added in v0.1.18.\n- Event `unhandledRejection` added in v1.4.1.\n\n# Install\n\n```\n$ npm install --save uncaught\n```\n\n# Usage examples\n\n#### Browser\n\n```html\n\u003cbody\u003e\n    ...\n    \u003cscript src=\"path_to_your_project_dir/node_modules/uncaught/lib/index.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n        uncaught.start();\n        uncaught.addListener(function (error) {\n            console.log('Uncaught error or rejection: ', error.message);\n        });\n    \u003c/script\u003e\n    ...\n\u003c/body\u003e\n```\n\n#### Browser + webpack\n \n```js\nvar uncaught = require('uncaught');\n\nuncaught.start();\nuncaught.addListener(function (error) {\n    console.log('Uncaught error or rejection: ', error.message);\n});\n```\n\n#### Node.js\n\n```js\nvar uncaught = require('uncaught');\n\nuncaught.start();\nuncaught.addListener(function (error) {\n    console.log('Uncaught error or rejection: ', error.message);\n});\n```\n\n# API\n\nList of methods for module management:\n\n- `start`\nStarts handling of uncaught errors and promise rejection.\n\n- `stop`\nStops handling.\n\n- `addListener`\nAdds listener function to list. This function is called with uncaught error or promise rejection information:\n\n    - `error` object.\n\n    - In browser mode `event` object is sent as well.\n\n\n- `removeListener`\nRemoves listener function from list.\n\n- `removeAllListeners`\nRemoves all listeners functions.\n\n- `flush`\nFlushes the module: removes all listeners functions and stops handling of uncaught errors and promise rejections.\n\n# License\n\nMIT © https://github.com/aleksandr-oleynikov\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksandr-oleynikov%2Funcaught","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faleksandr-oleynikov%2Funcaught","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faleksandr-oleynikov%2Funcaught/lists"}