Skip to content

Conversation

@dwisiswant0
Copy link
Member

Follow up on projectdiscovery/nuclei#6326

changes:

  • add wrappedErr field to enrichedError to maintain error chains.
  • implement Unwrap() method to supports builtin errors.Is/errors.As.
  • refactor Wrap() method to preserve err chains instead of str concat.
  • update NewWithErr() to properly wrap errors while preserving tags & stacktrace.
  • enhance Equal() method to check wrapped error chains using errors.Is.
  • improve IsAny() func to use bidirectional errors.Is checking.

so basically these changes enable runtime type assertion via builtin errors.Is/errors.As func for granular error handling in call stacks while maintaining backward compatibility w/ existing enriched error feats.

* add `wrappedErr` field to `enrichedError` to
  maintain error chains.
* implement `Unwrap()` method to supports builtin
  `errors.Is`/`errors.As`.
* refactor `Wrap()` method to preserve err chains
  instead of str concat.
* update `NewWithErr()` to properly wrap errors
  while preserving tags & stacktrace.
* enhance `Equal()` method to check wrapped error
  chains using `errors.Is`.
* improve `IsAny()` func to use bidirectional
  `errors.Is` checking.

so basically these changes enable runtime type
assertion via builtin `errors.Is`/`errors.As` func
for granular error handling in call stacks while
maintaining backward compatibility w/ existing
enriched error feats.

Signed-off-by: Dwi Siswanto <[email protected]>
@dwisiswant0 dwisiswant0 requested a review from Mzack9999 July 18, 2025 00:07
@Mzack9999 Mzack9999 merged commit d7ac269 into main Jul 18, 2025
7 checks passed
@Mzack9999 Mzack9999 deleted the dwisiswant0/refactor/errorutil/impl-proper-err-wrapping-w-stdlib-compat branch July 18, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

errorutil: enable runtime type assertion for granular error handling

3 participants