{"id":13670903,"url":"https://github.com/leihuang23/babel-plugin-catch-reporter","last_synced_at":"2025-04-27T13:33:15.657Z","repository":{"id":180731208,"uuid":"325521449","full_name":"leihuang23/babel-plugin-catch-reporter","owner":"leihuang23","description":"A babel plugin that automatically reports errors in your program","archived":false,"fork":false,"pushed_at":"2022-06-02T05:33:09.000Z","size":58,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T16:04:31.398Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leihuang23.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-12-30T10:30:39.000Z","updated_at":"2024-01-15T09:17:46.000Z","dependencies_parsed_at":"2023-07-14T07:49:57.038Z","dependency_job_id":null,"html_url":"https://github.com/leihuang23/babel-plugin-catch-reporter","commit_stats":null,"previous_names":["catmorphic/babel-plugin-catch-reporter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leihuang23%2Fbabel-plugin-catch-reporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leihuang23%2Fbabel-plugin-catch-reporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leihuang23%2Fbabel-plugin-catch-reporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leihuang23%2Fbabel-plugin-catch-reporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leihuang23","download_url":"https://codeload.github.com/leihuang23/babel-plugin-catch-reporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251145780,"owners_count":21543096,"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-08-02T09:00:52.543Z","updated_at":"2025-04-27T13:33:10.605Z","avatar_url":"https://github.com/leihuang23.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# babel-plugin-catch-reporter\n\nA babel plugin that:\n\n1. Add catch clause to your Promise if you forget to do so.\n2. Add a logger to all catch clauses, whether it's a catch block or a promise `.catch()` function call.\n3. Automatically import the logging service when needed.\n\n## Config:\n\n-   `name: string` - The name of the your logging service.\n-   `source: string` - The import path name of your logging service.\n-   `methodName: string` - Which logging method to invoke.\n-   `catchPromise: boolean` - Whether to catch promises.\n-   `namespaced: boolean` - Whether to import the logging service as a namespace module.\n\n## Demo\n\n`.babelrc.json`\n\n```json\n{\n    \"plugins\": [\n        [\n            \"babel-plugin-catch-reporter\",\n            {\n                \"name\": \"Sentry\",\n                \"source\": \"@sentry/node\",\n                \"methodName\": \"captureException\",\n                \"catchPromise\": true,\n                \"namespaced\": true\n            }\n        ]\n    ]\n}\n```\n\n`src/foo.js`\n\n```js\nexport function noop() {\n    try {\n        return nonexistent\n    } catch (ignore) {\n        // console.log(ignore);\n    }\n}\n\nexport function bar() {\n    return fetch('https://google.com').json().then(console.log)\n}\n\nexport function baz() {\n    return fetch('https://google.com')\n        .json()\n        .then(console.log)\n        .catch((e) =\u003e {\n            console.error(e)\n        })\n}\n```\n\ngets compiled to:\n\n```js\nimport * as Sentry from '@sentry/node'\nexport function noop() {\n    try {\n        return nonexistent\n    } catch (ignore) {\n        // console.log(ignore);\n\n        Sentry.captureException(ignore)\n    }\n}\nexport function bar() {\n    return fetch('https://google.com')\n        .json()\n        .then(console.log)\n        .catch(function (_e) {\n            Sentry.captureException(_e)\n        })\n}\nexport function baz() {\n    return fetch('https://google.com')\n        .json()\n        .then(console.log)\n        .catch((e) =\u003e {\n            Sentry.captureException(e)\n            console.error(e)\n        })\n}\n```\n\n`src/bar.js`\n\n```js\nfetch().json().then(console.log)\n```\n\ngets compiled to:\n\n```js\nimport * as Sentry from '@sentry/node'\nfetch()\n    .json()\n    .then(console.log)\n    .catch(function (_e) {\n        Sentry.captureException(_e)\n    })\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleihuang23%2Fbabel-plugin-catch-reporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleihuang23%2Fbabel-plugin-catch-reporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleihuang23%2Fbabel-plugin-catch-reporter/lists"}