{"id":23692500,"url":"https://github.com/yext/yerrors","last_synced_at":"2025-09-02T20:33:14.183Z","repository":{"id":57561647,"uuid":"307417776","full_name":"yext/yerrors","owner":"yext","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-16T03:04:15.000Z","size":15,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-30T14:34:06.053Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yext.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-26T15:27:42.000Z","updated_at":"2023-07-16T03:04:20.000Z","dependencies_parsed_at":"2024-06-19T14:58:08.844Z","dependency_job_id":"aa9e64cb-11df-4ee8-b0ad-3ec896144220","html_url":"https://github.com/yext/yerrors","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/yext%2Fyerrors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fyerrors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fyerrors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yext%2Fyerrors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yext","download_url":"https://codeload.github.com/yext/yerrors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231810497,"owners_count":18430000,"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-30T03:28:24.397Z","updated_at":"2024-12-30T03:28:28.660Z","avatar_url":"https://github.com/yext.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# yerrors [![GoDoc](https://godoc.org/github.com/yext/yerrors?status.svg)](http://godoc.org/github.com/yext/yerrors) [![Report card](https://goreportcard.com/badge/github.com/yext/yerrors)](https://goreportcard.com/report/github.com/yext/yerrors)\n`import \"github.com/yext/yerrors\"`\n\n* [Overview](#pkg-overview)\n* [Index](#pkg-index)\n\n## \u003ca name=\"pkg-overview\"\u003eOverview\u003c/a\u003e\nPackage yerrors wraps [golang.org/x/xerrors](https://golang.org/x/xerrors) to support a\nno-context Wrapper.\n\nThe party line is that error traces should include meaningful context at each\nstep. If there's no meaningful context to add, then omitting the stack frame\nis ok. This policy leads to concise stack traces, especially compared to\nenterprise development in Java.\n\nHowever, the ability to record a stack trace without providing context is\nuseful in some places, and the community-favorite `pkg/errors` supported\nthat. The official solution (xerrors) does not.\n\nThis package provides a no-context Wrapper that is compatible with xerrors.\n\n### Summary\n\n- yerrors.Wrap will add a stack frame to the error without modifying the\n  error's message, printed when formatted with \"%+v\", but not with \"%v\".\n\n- yerrors.Mask does the same thing, while preventing `As` or `Is` from\n  introspecting the error it wraps.\n\n- The above functionality depends on using yerrors.Errorf instead of\n  xerrors.Errorf, so we also supply aliases to all of the commonly-used\n  things within the xerrors package.\n\nThis package should be used to replace all xerrors usage, due to the last\npoint above.\n\n### Example\nTaking this error as an example:\n\n\n\terr := yerrors.Errorf(\"some context: %w\",\n\t  yerrors.Wrap(\n\t    yerrors.New(\"an error\")))\n\nIt would include all 3 invocations in the stack trace, e.g. when printed like\nthis:\n\n\n\tfmt.Printf(\"%+v\", err)\n\nIt would include only the two pieces of content in the error message:\n\n\n\terr.Error() == fmt.Sprintf(\"%v\", err)\n\n\t// Output: \"some context: an error\"\n\nSee xerrors_test.go for a complete example.\n\n\n\n\n## \u003ca name=\"pkg-index\"\u003eIndex\u003c/a\u003e\n* [Variables](#pkg-variables)\n* [func Errorf(format string, a ...interface{}) error](#Errorf)\n* [func Mask(err error) error](#Mask)\n* [func Wrap(err error) error](#Wrap)\n* [func WrapFrame(err error, caller int) error](#WrapFrame)\n* [type Wrapper](#Wrapper)\n\n\n#### \u003ca name=\"pkg-files\"\u003ePackage files\u003c/a\u003e\n[doc.go](/src/target/doc.go) [fmt.go](/src/target/fmt.go) [xerrors.go](/src/target/xerrors.go)\n\n\n\n## \u003ca name=\"pkg-variables\"\u003eVariables\u003c/a\u003e\n``` go\nvar (\n    New    = xerrors.New\n    Is     = xerrors.Is\n    As     = xerrors.As\n    Unwrap = xerrors.Unwrap\n    Opaque = xerrors.Opaque\n)\n```\n\n\n## \u003ca name=\"Errorf\"\u003efunc\u003c/a\u003e [Errorf](/src/target/fmt.go?s=1321:1371#L38)\n``` go\nfunc Errorf(format string, a ...interface{}) error\n```\nErrorf formats according to a format specifier and returns the string as a\nvalue that satisfies error.\n\nThe returned error includes the file and line number of the caller when\nformatted with additional detail enabled. If the last argument is an error\nthe returned error's Format method will return it if the format string ends\nwith \": %s\", \": %v\", or \": %w\". If the last argument is an error and the\nformat string ends with \": %w\", the returned error implements an Unwrap\nmethod returning it.\n\nIf the format specifier includes a %w verb with an error operand in a\nposition other than at the end, the returned error will still implement an\nUnwrap method returning the operand, but the error's Format method will not\nreturn the wrapped error.\n\nIt is invalid to include more than one %w verb or to supply it with an\noperand that does not implement the error interface. The %w verb is otherwise\na synonym for %v.\n\n\n\n## \u003ca name=\"Mask\"\u003efunc\u003c/a\u003e [Mask](/src/target/xerrors.go?s=996:1022#L40)\n``` go\nfunc Mask(err error) error\n```\nMask returns the given error opaquely wrapped, without additional context.\nAs a special case, a nil argument results in a nil return.\n\n\n\n## \u003ca name=\"Wrap\"\u003efunc\u003c/a\u003e [Wrap](/src/target/xerrors.go?s=470:496#L22)\n``` go\nfunc Wrap(err error) error\n```\nWrap returns the given error transparently wrapped, without additional context.\nAs a special case, a nil argument results in a nil return.\n\n\n\n## \u003ca name=\"WrapFrame\"\u003efunc\u003c/a\u003e [WrapFrame](/src/target/xerrors.go?s=718:761#L31)\n``` go\nfunc WrapFrame(err error, caller int) error\n```\nWrapFrame is like Wrap, except uses the location a given number of stack frames up.\nWrapFrame(err, 0) is equivalent to Wrap(err).\n\n\n\n\n## \u003ca name=\"Wrapper\"\u003etype\u003c/a\u003e [Wrapper](/src/target/xerrors.go?s=170:200#L10)\n``` go\ntype Wrapper = xerrors.Wrapper\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n- - -\nGenerated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyext%2Fyerrors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyext%2Fyerrors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyext%2Fyerrors/lists"}