{"id":22086232,"url":"https://github.com/imjaroiswebdev/go-poc-contextual-error-handling","last_synced_at":"2025-03-23T22:18:30.728Z","repository":{"id":123516022,"uuid":"338463490","full_name":"imjaroiswebdev/go-poc-contextual-error-handling","owner":"imjaroiswebdev","description":"[POC] Contextual Error Information Handling for Catched Error in Transport Layer","archived":false,"fork":false,"pushed_at":"2021-02-21T22:13:47.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-28T14:58:18.644Z","etag":null,"topics":[],"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/imjaroiswebdev.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":"2021-02-13T00:12:51.000Z","updated_at":"2024-06-19T10:25:50.234Z","dependencies_parsed_at":null,"dependency_job_id":"c1831f0a-dbb5-46a0-bbee-eacab979fabd","html_url":"https://github.com/imjaroiswebdev/go-poc-contextual-error-handling","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/imjaroiswebdev%2Fgo-poc-contextual-error-handling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjaroiswebdev%2Fgo-poc-contextual-error-handling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjaroiswebdev%2Fgo-poc-contextual-error-handling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjaroiswebdev%2Fgo-poc-contextual-error-handling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imjaroiswebdev","download_url":"https://codeload.github.com/imjaroiswebdev/go-poc-contextual-error-handling/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245175532,"owners_count":20572792,"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-12-01T01:22:21.987Z","updated_at":"2025-03-23T22:18:30.706Z","avatar_url":"https://github.com/imjaroiswebdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [POC] Contextual Error Information Handling for Catched Error in Transport Layer\n\nThe intend of the **POC** is to validate some about and to settled an approach for handling error contextual information at Transport Layer (http transport in this particular case) in a `Go` application.\n\nSo for a **Business Logic** error catched a *Transport Layer* we can be able to index a richer error interface valuable to this specific transport (`http - application/json`).\n\n## POC Result\n\n```bash\nPrinting mapped errors...\n\nMapping error errVerbSvcTimeout\nError from Business Logic⤵️\n        yasvc internal call got timeout: ya504\nPrinting Response json...\n{\n  \"httpStatus\": 504,\n  \"data\": null,\n  \"error\": {\n    \"op\": \"verbSvc\",\n    \"code\": \"errTimeout\",\n    \"message\": \"internal timeout\",\n    \"meta\": null\n  },\n  \"extra\": null\n}\nMapping error errVerbSvcInvalidInput\nError from Business Logic⤵️\n        yasvc input validation error: ya bad input received\nPrinting Response json...\n{\n  \"httpStatus\": 400,\n  \"data\": null,\n  \"error\": {\n    \"op\": \"verbSvc\",\n    \"code\": \"errInvalidInput\",\n    \"message\": \"input validation error\",\n    \"meta\": null\n  },\n  \"extra\": null\n}\nMapping error errVerbSvcInvalidSession\nError from Business Logic⤵️\n        yasvc invalid session: this user closed its session\nPrinting Response json...\n{\n  \"httpStatus\": 403,\n  \"data\": null,\n  \"error\": {\n    \"op\": \"verbSvc\",\n    \"code\": \"errInvalidSession\",\n    \"message\": \"invalid session\",\n    \"meta\": null\n  },\n  \"extra\": null\n}\nMapping error errVerbSvcInternal\nError from Business Logic⤵️\n        yasvc internal error: Traditional Java null pointer exception\nPrinting Response json...\n{\n  \"httpStatus\": 500,\n  \"data\": null,\n  \"error\": {\n    \"op\": \"verbSvc\",\n    \"code\": \"errInternal\",\n    \"message\": \"internal error\",\n    \"meta\": null\n  },\n  \"extra\": null\n}\nHandling an unmapped error with an Internal Error\nError from Business Logic⤵️\n        yasvc not an authenticated user: who is this user?\nPrinting Response json...\n{\n  \"httpStatus\": 500,\n  \"data\": null,\n  \"error\": {\n    \"op\": \"verbSvc\",\n    \"code\": \"errInternal\",\n    \"message\": \"internal error\",\n    \"meta\": null\n  },\n  \"extra\": null\n}\n```\n## Test Coverage Result\n\n```bash\nmain.go:29:   Error                   100.0%\nmain.go:33:   Unwrap                  100.0%\nmain.go:57:   justPrint               0.0%\nmain.go:111:  MapErrorToResponseError 100.0%\nmain.go:135:  main                    0.0%\ntotal:        (statements)            15.9%\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjaroiswebdev%2Fgo-poc-contextual-error-handling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimjaroiswebdev%2Fgo-poc-contextual-error-handling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjaroiswebdev%2Fgo-poc-contextual-error-handling/lists"}