{"record":{"id":"9ed35bfba19c71aa","repo":"apache/beam","slug":"s-errors","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"sdks/go/pkg/beam/internal/errors/errors.go","lineNumber":28,"sourceCode":"// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Package errors contains functionality for creating and wrapping errors with improved formatting\n// compared to the standard Go error functionality.\npackage errors\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"strings\"\n)\n\n// New returns an error with the given message.\nfunc New(message string) error {\n\treturn fmt.Errorf(\"%s\", message)\n}\n\n// Errorf returns an error with a message formatted according to the format\n// specifier.\nfunc Errorf(format string, args ...any) error {\n\treturn fmt.Errorf(format, args...)\n}\n\n// Wrap returns a new error annotating err with a new message.\nfunc Wrap(err error, message string) error {\n\tif err == nil {\n\t\treturn nil\n\t}\n\treturn &beamError{\n\t\tcause: err,\n\t\tmsg:   message,\n\t\ttop:   getTop(err),\n\t}","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/internal/errors/errors.go#L10-L46","documentation":"Beam's internal/errors package provides New(message), which wraps fmt.Errorf(\"%s\", message) so that wrapped errors carry no stack traces in test recordings and are matchable. The raw message \"%s\" is the format specifier itself; the actual error text is whatever string was passed to errors.New.","triggerScenarios":"Any call to github.com/apache/beam/sdks/go/pkg/beam/internal/errors.New with a message string — e.g. ErrNoUnit, ErrNoUser, GetContentTree, verifyRouter, setupSdkCatalog failures.","commonSituations":"Seeing this in stack traces when a Beam component (artifact service, catalog setup, router verification) returns a plain constructed error; the underlying cause is in the message argument, not this wrapper.","solutions":["Read the actual error message text contained in the error — this site is just the wrapping point.","Trace the caller (e.g. GetContentTree, verifyRouter, setupSdkCatalog) to fix the root cause.","If you need richer diagnostics, use errors.Wrap/Errorf from the same package to add context."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := operation(ctx); err != nil {\n    var e error\n    errors.As(err, &e)\n    log.Printf(\"beam internal error: %v\", e) // read actual message\n}","preventionTips":["Treat this as a wrapper: always read the embedded message.","Log full error chains (errors.Unwrap) when debugging Beam internals."],"tags":["go","errors","wrapper"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}