{"id":18412062,"url":"https://github.com/elliotxx/errors","last_synced_at":"2025-04-12T23:45:18.728Z","repository":{"id":59047316,"uuid":"534233538","full_name":"elliotxx/errors","owner":"elliotxx","description":"An errors package for web development in Golang.","archived":false,"fork":false,"pushed_at":"2023-07-26T09:37:32.000Z","size":544,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T23:45:07.906Z","etag":null,"topics":["errors","go","golang","webapp"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/elliotxx/errors","language":"Go","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/elliotxx.png","metadata":{"files":{"readme":"README-zh.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-08T13:48:52.000Z","updated_at":"2023-07-26T09:52:29.000Z","dependencies_parsed_at":"2024-06-23T00:31:59.409Z","dependency_job_id":null,"html_url":"https://github.com/elliotxx/errors","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Ferrors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Ferrors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Ferrors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotxx%2Ferrors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elliotxx","download_url":"https://codeload.github.com/elliotxx/errors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647260,"owners_count":21139081,"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":["errors","go","golang","webapp"],"created_at":"2024-11-06T03:39:36.680Z","updated_at":"2025-04-12T23:45:18.699Z","avatar_url":"https://github.com/elliotxx.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align = \"center\"\u003e\n\u003cp\u003e\n    \u003cimg width=\"160\" src=\"https://github.com/elliotxx/errors/blob/master/golang-logo.png?sanitize=true\"\u003e\n\u003c/p\u003e\n\u003ch2\u003e一个适应于 Web 开发的 Golang 错误包\u003c/h2\u003e\n\u003ca title=\"Go Reference\" target=\"_blank\" href=\"https://pkg.go.dev/github.com/elliotxx/errors\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/elliotxx/errors.svg\"\u003e\u003c/a\u003e\n\u003ca title=\"Go Report Card\" target=\"_blank\" href=\"https://goreportcard.com/report/github.com/elliotxx/errors\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/elliotxx/errors?style=flat-square\"\u003e\u003c/a\u003e\n\u003ca title=\"Coverage Status\" target=\"_blank\" href=\"https://coveralls.io/github/elliotxx/errors?branch=master\"\u003e\u003cimg src=\"https://img.shields.io/coveralls/github/elliotxx/errors/master\"\u003e\u003c/a\u003e\n\u003ca title=\"Code Size\" target=\"_blank\" href=\"https://github.com/elliotxx/errors\"\u003e\u003cimg src=\"https://img.shields.io/github/languages/code-size/elliotxx/errors.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003cbr\u003e\n\u003ca title=\"GitHub release\" target=\"_blank\" href=\"https://github.com/elliotxx/errors/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/elliotxx/errors.svg\"\u003e\u003c/a\u003e\n\u003ca title=\"License\" target=\"_blank\" href=\"https://github.com/elliotxx/errors/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/elliotxx/errors\"\u003e\u003c/a\u003e\n\u003ca title=\"GitHub Commits\" target=\"_blank\" href=\"https://github.com/elliotxx/errors/commits/master\"\u003e\u003cimg src=\"https://img.shields.io/github/commit-activity/m/elliotxx/errors.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003ca title=\"Last Commit\" target=\"_blank\" href=\"https://github.com/elliotxx/errors/commits/master\"\u003e\u003cimg src=\"https://img.shields.io/github/last-commit/elliotxx/errors.svg?style=flat-square\u0026color=FF9900\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n`elliotxx/errors` 是一个适应于 Web 开发的 Golang 错误包，启发于 [pkg/errors](https://github.com/pkg/errors)!\n\n## 📜 语言\n\n[English](https://github.com/elliotxx/errors/blob/master/README.md) | [简体中文](https://github.com/elliotxx/errors/blob/master/README-zh.md)\n\n## ⚡ 使用\n\n```\ngo get -u github.com/elliotxx/errors\n```\n\n## ✨ 特性\n\n* 更详细的错误信息，比如错误码、错误信息、错误原因、错误堆栈等\n* 更强大的 API\n* 轻量级\n\n## 📚 样例\n\n样例 1:\n\n```go\npackage errcodes\n\nimport \"github.com/elliotxx/errors\"\n\nvar (\n\tSuccess                    = errors.NewErrorCode(\"00000\", \"success\")\n\tNotFound                   = errors.NewErrorCode(\"A0100\", \"not found\")\n\tAccessPermissionError      = errors.NewErrorCode(\"A0200\", \"abnormal access permission\")\n\tAbnormalUserOperation      = errors.NewErrorCode(\"A0300\", \"abnormal user operation\")\n\tInvalidParams              = errors.NewErrorCode(\"A0400\", \"invalid params\")\n\tBlankRequiredParams        = errors.NewErrorCode(\"A0401\", \"required parameter is blank\")\n\tMalformedParams            = errors.NewErrorCode(\"A0403\", \"parameter format mismatch\")\n\tServerError                = errors.NewErrorCode(\"A0500\", \"server error\")\n\tTooManyRequests            = errors.NewErrorCode(\"A0501\", \"too many requests\")\n\tConcurrentExceedLimit      = errors.NewErrorCode(\"A0502\", \"the request parallel number exceeds the limit\")\n\tWaitUserOperation          = errors.NewErrorCode(\"A0503\", \"please wait for user operation\")\n\tRepeatedRequest            = errors.NewErrorCode(\"A0504\", \"repeated request\")\n)\n```\n\n样例 2:\n\n```go\ndetailErr := New(\"name is empty\")\n// detailErr.Error() returns \"cause [name is empty]\"\n\nErrBlankParameter := NewErrorCode(\"A0401\", \"required parameter is blank\")\n// ErrBlankParameter.Error() returns \"code [A0401], msg [required parameter is blank]\"\n\ndetailErr = NewDetailError(\"A0401\", \"required parameter is blank\", fmt.Errorf(\"name is empty\"))\n// detailErr.Error() returns \"code [A0401], msg [required parameter is blank], cause [name is empty]\"\n\ndetailErr = Errorf(\"%s is not exist\", \"John\")\n// detailErr.Error() returns \"cause [John is not exist]\"\n\ndetailErr = Code(\"A0401\").Msg(\"required parameter is blank\").Cause(fmt.Errorf(\"name is empty\"))\n// detailErr.Error() returns \"code [A0401], msg [required parameter is blank], cause [name is empty]\"\n\ndetailErr = Code(\"A0401\").Msg(\"required parameter is blank\")\n// detailErr.Error() returns \"code [A0401], msg [required parameter is blank]\"\n\ndetailErr = Code(\"A0401\").Cause(fmt.Errorf(\"name is empty\"))\n// detailErr.Error() returns \"code [A0401], cause [name is empty]\"\n\ndetailErr = Code(\"A0401\").Causef(\"name is empty\")\n// detailErr.Error() returns \"code [A0401], cause [name is empty]\"\n\ndetailErr = Code(\"A0401\").Causef(\"%s is empty\", \"name\")\n// detailErr.Error() returns \"code [A0401], cause [name is empty]\"\n\nrootCause := fmt.Errorf(\"name is empty\")\ndetailErr = Code(\"A0401\").Causewf(rootCause, \"failed to validate parameter\")\n// detailErr.Error() returns \"code [A0401], cause [failed to validate parameter: name is empty]\"\n\ndetailErr = Msg(\"required parameter is blank\")\n// detailErr.Error() returns \"msg [required parameter is blank]\"\n\ndetailErr = ErrBlankParameter.Cause(fmt.Errorf(\"name is empty\"))\n// detailErr.Error() returns \"code [A0401], msg [required parameter is blank], cause [name is empty]\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotxx%2Ferrors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felliotxx%2Ferrors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotxx%2Ferrors/lists"}