Add HasCallStack constraints to error call sites#1175
Draft
Add HasCallStack constraints to error call sites#1175
Conversation
First step of ADR-011: add HasCallStack constraints to functions that call error, so that impossible-state violations produce call stack traces for easier debugging. This covers ~30 functions across 19 files without introducing the IoeWrapper machinery.
…nctions These functions either have temporary Dijkstra era placeholders (which will be removed when Dijkstra is supported) or validation TODOs that should be replaced with proper error handling rather than HasCallStack.
Dijkstra-era error placeholders don't need HasCallStack since the error messages already identify the function. Fix error messages that were missing the function name (fromShelleyMultiSig, fromAllegraTimelock, getPlutusDatum, getAnchorDataFromCertificate).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Context
Implements the first step of ADR-011: Better call stacks of IO exceptions.
This PR adds
HasCallStackconstraints to ~30 functions across 19 files that containerrorcalls guarding logically impossible states (e.g. "Impossible! History should always be non-empty", Dijkstra era not-yet-supported guards). When these errors fire, the call stack trace will now be included in the error output, making debugging significantly easier.This is the simple, low-risk approach: just threading
HasCallStackthrough existing functions. It does not introduce theCIO/runIO/IoeWrappermachinery from the full ADR, which would disrupt the exception catching hierarchy.Two error call sites were intentionally skipped because they are inside type class instance methods (
ToJSON,HasTypeProxy) where the class definition doesn't supportHasCallStack.How to trust this PR
HasCallStackconstraints only add call stack propagation, they don't change runtime behaviorCardano.Api.Error(throwErrorM,liftEitherError)cabal build cardano-api:lib:cardano-apiChecklist