_examples

command
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package main demonstrates basic usage of the errors package from github.com/olekukonko/errors. It showcases creating simple errors, formatted errors, errors with stack traces, and named errors, highlighting the package’s enhanced error handling capabilities.

Package main demonstrates error wrapping and chaining using the errors package from github.com/olekukonko/errors. It simulates a layered application (API, business logic, database) where errors are created, enriched with context, and wrapped, then inspected to show the full error chain and specific error checks.

Package main demonstrates the use of context in the errors package from github.com/olekukonko/errors. It showcases adding context to custom errors, accessing context through wrapped and converted errors, handling standard library errors, and working with complex context data structures.

Package main demonstrates the use of MultiError from github.com/olekukonko/errors to handle multiple validation and system errors. It showcases form validation with custom formatting, error filtering, and system error aggregation with retryable conditions, illustrating error management in a user registration and system monitoring context.

Package main demonstrates the use of MultiError with sampling from github.com/olekukonko/errors. It generates a large number of errors, applies sampling with a limit, and analyzes the results, showcasing error collection, custom formatting, and statistical reporting in a simulated error-heavy scenario.

Package main demonstrates the use of the IsNull method from github.com/olekukonko/errors. It tests various scenarios involving nil errors, empty errors, errors with null or non-null context, and MultiError instances, showcasing how IsNull determines nullability based on content and context, particularly with SQL null types.

Package main demonstrates the retry functionality of github.com/olekukonko/errors. It simulates flaky database and external service operations with configurable retries, exponential backoff, jitter, and context timeouts, showcasing error handling, retry policies, and result capturing in various failure scenarios.

Package main demonstrates the use of WithStack from github.com/olekukonko/errors. It showcases adding stack traces to errors using both package-level and method-style approaches, comparing their application to standard and enhanced errors, and combining them in a real-world scenario with additional context and error details.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL