From 926cca58d6bc255171e6c942419eeb222b28eba4 Mon Sep 17 00:00:00 2001 From: Prashant V Date: Sun, 10 Nov 2024 08:43:58 -0800 Subject: [PATCH] Update CHANGELOG for `GetCaller` --- CHANGELOG.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c13f21e..76e3dff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Added -- Add UnwrapFrame function to extract a single frame from an error. +- Add `UnwrapFrame` function to extract a single frame from an error. You can use this to implement your own trace formatting logic. - Support extracting trace frames from custom errors. Any error value that implements `TracePC() uintptr` will now contribute to the trace. +- Add `GetCaller` function for error helpers to annotate wrapped errors with + their caller information instead of the helper. Example: + + ```go + //go:noinline + func Wrapf(err error, msg string, args ...any) { + caller := errtrace.GetCaller() + err := ... + return caller.Wrap(err) + } + ``` + - cmd/errtrace: Add `-no-wrapn` option to disable wrapping with generic `WrapN` functions. This is only useful for toolexec mode due to tooling limitations.