Package errors provides simple error handling primitives. The traditional error handling idiom in Go that is applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. Wrap function returns a new error that adds context to the original error. Using errors.Wrap constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by errors.Cause. errors.Cause will recursively retrieve the topmost error which does not implement causer, which is assumed to be the original cause.

Features

  • Add context to an error
  • Formatted printing of errors
  • Retrieve the cause of an error
  • Retrieve the stack trace of an error or wrapper
  • Wrap constructs a stack of errors, adding context to the preceding error
  • Depending on the nature of the error it may be necessary to reverse the operation of errors

Project Samples

Project Activity

See All Activity >

License

BSD License

Follow errors

errors Web Site

Other Useful Business Software
Auth0 for AI Agents now in GA Icon
Auth0 for AI Agents now in GA

Ready to implement AI with confidence (without sacrificing security)?

Connect your AI agents to apps and data more securely, give users control over the actions AI agents can perform and the data they can access, and enable human confirmation for critical agent actions.
Start building today
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of errors!

Additional Project Details

Programming Language

Go

Related Categories

Go Debuggers, Go Package Managers

Registered

2021-08-17