{"id":15509557,"url":"https://github.com/huan/gerror","last_synced_at":"2026-05-12T23:33:39.629Z","repository":{"id":65334808,"uuid":"423086566","full_name":"huan/gerror","owner":"huan","description":"Mixer of gRPC Error \u0026 ECMAScript Error","archived":false,"fork":false,"pushed_at":"2021-11-24T15:30:42.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-21T02:18:38.108Z","etag":null,"topics":["error","grpc","status"],"latest_commit_sha":null,"homepage":"https://paka.dev/npm/gerror","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huan.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":"2021-10-31T07:54:15.000Z","updated_at":"2021-11-30T03:26:22.000Z","dependencies_parsed_at":"2023-01-17T13:15:49.110Z","dependency_job_id":null,"html_url":"https://github.com/huan/gerror","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huan/gerror","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huan%2Fgerror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huan%2Fgerror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huan%2Fgerror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huan%2Fgerror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huan","download_url":"https://codeload.github.com/huan/gerror/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huan%2Fgerror/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32961784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"ssl_error","status_checked_at":"2026-05-12T23:30:18.191Z","response_time":102,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["error","grpc","status"],"created_at":"2024-10-02T09:43:14.535Z","updated_at":"2026-05-12T23:33:39.616Z","avatar_url":"https://github.com/huan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GError\n\n[![NPM Version](https://badge.fury.io/js/gerror.svg)](https://badge.fury.io/js/gerror)\n[![NPM](https://github.com/huan/gerror/workflows/NPM/badge.svg)](https://github.com/huan/gerror/actions?query=workflow%3ANPM)\n[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/)\n[![ES Modules](https://img.shields.io/badge/ES-Modules-brightgreen)](https://github.com/Chatie/tsconfig/issues/16)\n\nMixer of gRPC Error \u0026amp; ECMAScript Error\n\n![GError](docs/images/gerror-logo.png)\n\n## Motivation\n\nWe are writing async programs with gRPC with Node.js(ECMAScript) so we need to mix gRPC Error \u0026amp; ECMAScript Error.\n\nIn order to make it easy, we build GError module\n\n## Features\n\n1. `GError.from(anyting: any)`\n1. `gerror.toJSON()`\n\n## Examples\n\nTBW\n\n## API Reference\n\n### `class GError`\n\n`GError` can be used to replace the standard `Error` as a drop in replacement.\n\n```ts\nimport { GError } from 'gerror'\n\nconst gerror = GError.from(new Error('test'))\n```\n\n### `GError.stringify(e: any)`\n\nConvert anything to a `JSON.stringify()`-ed `GError` payload\n\n```ts\nGError.stringify('this is a string error')\n\n// It acepts any type of args\nGError.stringify(new Error() as unknown)\n```\n\n### `wrapAsyncError()`\n\nIt has been designed to convert a Async to Sync, for example:\n\n1. `async (...args: any[]) =\u003e Promise\u003cany\u003e` will be converted to `(...args: any[]) =\u003e void`\n1. `Promise\u003cany\u003e` will be converted to `void`\n\nThe error will be send via the `onError` callback.\n\n```ts\nimport { wrapAsyncError } from 'gerror'\n\nconst onError = (e: any) =\u003e console.error(e)\nconst wrapAsync = wrapAsyncError(onError)\n\nconst asyncFunc = async () =\u003e Promise.reject('rejection')\nconst syncFunc = wrapAsync(asyncFunc)\n// ReturnType\u003ctypeof syncFunc\u003e === 'void'\n\nasyncFunc() // \u003c- nothing happens (no unhandled rejections)\n// console.error('Rejection')\n```\n\n## Resources\n\n1. [Google Cloud APIs - Errors](https://cloud.google.com/apis/design/errors)\n\n## History\n\n### master v1.0 (Oct 30, 2021)\n\n1. Initial code from `wechaty-puppet` module\n1. Add `timeoutPromise()` function\n\n## Author\n\n[Huan LI](https://github.com/huan) ([李卓桓](http://linkedin.com/in/zixia)), Google Developer Export (GDE), zixia@zixia.net\n\n[![Profile of Huan LI (李卓桓) on StackOverflow](https://stackexchange.com/users/flair/265499.png)](https://stackexchange.com/users/265499)\n\n## Copyright \u0026 License\n\n* Docs released under Creative Commons\n* Code released under the Apache-2.0 License\n* Code \u0026 Docs © 2021 Huan LI \\\u003czixia@zixia.net\\\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuan%2Fgerror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuan%2Fgerror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuan%2Fgerror/lists"}