{"id":17407060,"url":"https://github.com/halorium/flaw","last_synced_at":"2025-10-15T10:28:12.646Z","repository":{"id":144213378,"uuid":"126040961","full_name":"halorium/flaw","owner":"halorium","description":"Custom Go Error Package","archived":false,"fork":false,"pushed_at":"2018-03-20T22:04:14.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T22:48:50.806Z","etag":null,"topics":["error","error-handling","errors","go","golang","stacktrace"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/halorium.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-20T15:34:38.000Z","updated_at":"2018-03-20T22:04:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8036f66-4c55-4d4f-a10b-3e57442eb518","html_url":"https://github.com/halorium/flaw","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/halorium/flaw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halorium%2Fflaw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halorium%2Fflaw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halorium%2Fflaw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halorium%2Fflaw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halorium","download_url":"https://codeload.github.com/halorium/flaw/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halorium%2Fflaw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279073208,"owners_count":26097347,"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","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","error-handling","errors","go","golang","stacktrace"],"created_at":"2024-10-16T22:23:51.149Z","updated_at":"2025-10-15T10:28:12.602Z","avatar_url":"https://github.com/halorium.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## flaw is a Go(lang) custom error package\n\n### Features\nThis was created because sometimes you need a little more information than what\nthe builtin error interface can provide.\n\nA flaw.Error allows you to \"Wrap\" your errors as they bubble up adding a message trace\nas well as a stack trace to your errors.\n\nThe flaw.Error interface implements the following interfaces:\n* builtin error interface\n* fmt.Stringer interface\n* json.Marshaler interface\n\nThis allows for detailed error message output in JSON formatted logs like\nLoggly and many others.\n\n### Usage\n```\ngo get github.com/halorium/flaw\n```\n\n```\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\n\t\"github.com/halorium/flaw\"\n)\n\nfunc main() {\n\tflawError := MyFunc1()\n\n\tif flawError != nil {\n\t\tfmt.Println(flawError)\n\t\t// original error from external call 2\n\n\t\tfmt.Println(flawError.String())\n\t\t// message trace\n\t\t// -----------\n\t\t// cannot perform MyFunc1 (main.go:34)\n\t\t// cannot perform MyFunc2 (main.go:46)\n\t\t// original error from external call 2 (main.go:46)\n\t\t//\n\t\t// stack trace\n\t\t// -----------\n\t\t// main.go:46\n\t\t// main.go:30\n\t\t// main.go:11\n\n\t\tdata, _ := json.Marshal(flawError)\n\t\tfmt.Println(string(data))\n\t\t// {\n\t\t//   \"message-trace\": [\n\t\t//     {\n\t\t//       \"message\": \"cannot perform MyFunc1\",\n\t\t//       \"pathname\": \"main.go\",\n\t\t//       \"line\": 50\n\t\t//     },\n\t\t//     {\n\t\t//       \"message\": \"cannot perform MyFunc2\",\n\t\t//       \"pathname\": \"main.go\",\n\t\t//       \"line\": 62\n\t\t//     },\n\t\t//     {\n\t\t//       \"message\": \"original error from external call 2\",\n\t\t//       \"pathname\": \"main.go\",\n\t\t//       \"line\": 62\n\t\t//     }\n\t\t//   ],\n\t\t//   \"stack-trace\": [\n\t\t//     {\n\t\t//       \"pathname\": \"main.go\",\n\t\t//       \"line\": 62\n\t\t//     },\n\t\t//     {\n\t\t//       \"pathname\": \"main.go\",\n\t\t//       \"line\": 46\n\t\t//     },\n\t\t//     {\n\t\t//       \"pathname\": \"main.go\",\n\t\t//       \"line\": 12\n\t\t//     }\n\t\t//   ]\n\t\t// }\n\t}\n}\n\nfunc MyFunc1() flaw.Error {\n\terr := ExternalCall1()\n\n\tif err != nil {\n\t\t// create a flaw Error from a standard error\n\t\t// wrap flaw with additional information\n\t\treturn flaw.From(err).Wrap(\"cannot perform ExternalCall1\")\n\t}\n\n\tflawError := MyFunc2()\n\n\tif flawError != nil {\n\t\t// wrap flaw with additional information\n\t\treturn flawError.Wrap(\"cannot perform MyFunc1\")\n\t}\n\n\treturn nil\n}\n\nfunc MyFunc2() flaw.Error {\n\terr := ExternalCall2()\n\n\tif err != nil {\n\t\t// create a flaw Error from a standard error\n\t\t// wrap flaw with additional information\n\t\treturn flaw.From(err).Wrap(\"cannot perform MyFunc2\")\n\t}\n\n\treturn nil\n}\n\nfunc ExternalCall1() error {\n\treturn nil\n}\n\nfunc ExternalCall2() error {\n\treturn errors.New(\"original error from external call 2\")\n}\n```\n\n#### Credits\nThis is a refactor from code designed and written by @tmornini and @halorium\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalorium%2Fflaw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalorium%2Fflaw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalorium%2Fflaw/lists"}