From fc3dac5190a121a562e09ca734e1f716240db32d Mon Sep 17 00:00:00 2001 From: "F." Date: Thu, 15 May 2025 15:33:41 +0200 Subject: [PATCH 1/2] docs(getting-started): add example for creating errors with context and logging --- docs/docs/getting-started/installation.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/docs/getting-started/installation.md b/docs/docs/getting-started/installation.md index 38e5fef..fc58a4d 100644 --- a/docs/docs/getting-started/installation.md +++ b/docs/docs/getting-started/installation.md @@ -20,6 +20,13 @@ err := ewrap.New("database connection failed") if err != nil { return ewrap.Wrap(err, "failed to process request") } + +// Create a new error with context +err := ewrap.Newf("operation failed: %w", err) + ewrap.WithContext(ctx, ewrap.ErrorTypeDatabase, ewrap.SeverityCritical), + ewrap.WithLogger(logger)) + +err.Log() ``` ### Advanced Error Context From c8ccd1f73604e288873070982bda825eb65902cf Mon Sep 17 00:00:00 2001 From: "F." <62474964+hyp3rd@users.noreply.github.com> Date: Thu, 15 May 2025 21:34:23 +0200 Subject: [PATCH 2/2] Update docs/docs/getting-started/installation.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- docs/docs/getting-started/installation.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/docs/getting-started/installation.md b/docs/docs/getting-started/installation.md index fc58a4d..8765563 100644 --- a/docs/docs/getting-started/installation.md +++ b/docs/docs/getting-started/installation.md @@ -22,9 +22,11 @@ if err != nil { } // Create a new error with context -err := ewrap.Newf("operation failed: %w", err) +err := ewrap.Newf( + "operation failed: %w", err, ewrap.WithContext(ctx, ewrap.ErrorTypeDatabase, ewrap.SeverityCritical), - ewrap.WithLogger(logger)) + ewrap.WithLogger(logger), +) err.Log() ```