From a6f15b8f7efa8d84e8bce4d41a24925630be48df Mon Sep 17 00:00:00 2001 From: Ilya Hontarau Date: Wed, 19 Jun 2024 09:14:23 +0200 Subject: [PATCH] Add unwrap methods for errors (#18) * Add unwrap methods for errors * Update comments --- bugsnag.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bugsnag.go b/bugsnag.go index a36cf16..a20aea4 100644 --- a/bugsnag.go +++ b/bugsnag.go @@ -28,6 +28,12 @@ type errorWithStackFrames struct { err stackTracer } +// Cause returns initial error, provides compatibility for pkg/errors chains. +func (w *errorWithStackFrames) Cause() error { return w.err } + +// Unwrap returns initial error, provides compatibility for Go 1.13 error chains. +func (w *errorWithStackFrames) Unwrap() error { return w.err } + func (e *errorWithStackFrames) Error() string { return e.err.Error() }