Oops is a Go library for structured error handling that serves as a drop-in replacement for the standard error type. It provides a fluent builder pattern to attach rich contextual information (error codes, domains, tags, key-value attributes, user/tenant data, HTTP request/response, timestamps, durations, hints, ownership) to errors, along with automatic stack trace capture and optional source code fragment extraction. The library implements the standard error interface, supports error wrapping and chaining, panic recovery, assertions, and integrates with major Go logging libraries (zap, zerolog, logrus, slog) via separate formatter packages. Its architecture centers on an immutable option chain (functional options) that defers stack frame symbolization to first read, minimizing allocation overhead for errors that are created but never inspected. Key entry points are the package-level functions (Wrap, Wrapf, New, Errorf, Join, Recover, Recoverf, Assert, Assertf) and the OopsErrorBuilder chainable methods. External dependencies are minimal: only github.com/oklog/ulid/v2, github.com/samber/lo, and go.opentelemetry.io/otel/trace for optional OpenTelemetry span context extraction. The codebase is well-tested, benchmarked, and follows Go best practices with comprehensive linting and security scanning.
swift-power-assert is a Swift library that provides a `#assert` macro, delivering detailed diagnostic diagrams for assertion failures. The macro, built on SwiftSyntax, rewrites expressions to capture intermediate values and renders a tree of sub-expression results on failure, including word/line diffs for string comparisons. It supports sync and async evaluation, short-circuiting, and custom operators, aiming to replace multiple assertion APIs (XCTest, Nimble, etc.) with a single, universal assert. The package also includes a `StringWidth` module for accurate Unicode width calculations and a comprehensive test suite (2300+ lines) covering diverse expression types. Additionally, the repository contains an interactive web playground with a Deno backend and Monaco editor, allowing users to test the macro in a browser. The codebase is well-structured, with clean abstractions in the runtime library and plugin, though the macro rewriter is tightly coupled to the capture pattern and the generated Unicode width table is large.
A PHP library that provides a type-safe, static analysis-friendly way to narrow down mixed or union types at runtime. The core is a `Type` class (entry point via `type()` helper) that offers methods like `asString()`, `asInt()`, `as(ClassName::class)`, etc., each performing a runtime assertion and returning the narrowed type. It leverages PHPStan/Psalm's `@phpstan-assert-if-true` annotations to allow static analyzers to infer the narrowed type, preserving generic type information (e.g., `Collection<int, User>`). The library includes a `Not` class for negation checks (e.g., `type($x)->not()->null()`). It is part of the Pinkary Project, requires PHP 8.2+, and has zero runtime dependencies. The source is meticulously crafted with full test coverage, type-strict coding, and continuous integration enforcing linting, static analysis, and type coverage. It is a model example of how to expose runtime assertion functions with first-class static analysis support.