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
MongoDB Atlas runs apps anywhere Icon
MongoDB Atlas runs apps anywhere

Deploy in 115+ regions with the modern database for every enterprise.

MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free
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