Skip to content

Preserve original exception identity through train pipeline#16

Merged
Theauxm merged 1 commit into
mainfrom
fix/preserve-original-exception
Apr 3, 2026
Merged

Preserve original exception identity through train pipeline#16
Theauxm merged 1 commit into
mainfrom
fix/preserve-original-exception

Conversation

@Theauxm

@Theauxm Theauxm commented Apr 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Stop mutating exception messages via reflection in RailwayJunction — store TrainExceptionData in Exception.Data instead, preserving the original message for callers outside Trax
  • Use ExceptionDispatchInfo in ResolveOrThrow to preserve original stack traces through the Monad pipeline
  • Add StackTrace field to TrainExceptionData to capture the original throw site at catch time

Test plan

  • TrainExceptionDataTests — StackTrace serialization round-trip, null handling, backwards compat
  • JunctionCancellationTests — original message preserved, Exception.Data attached, stack trace captured
  • StackTracePreservationTests — end-to-end through Train.Run/RunEither verifying original stack trace, message, and type
  • JsonEscapingTests — rewritten to verify original message preserved + structured data in Exception.Data

Stop mutating exception messages via reflection — store TrainExceptionData
in Exception.Data instead. Use ExceptionDispatchInfo in ResolveOrThrow to
preserve original stack traces. Callers outside Trax now see the original
exception type, message, and stack trace.
@Theauxm
Theauxm merged commit cb45d0a into main Apr 3, 2026
1 check passed
@Theauxm
Theauxm deleted the fix/preserve-original-exception branch April 3, 2026 16:06
@traxsharp

traxsharp Bot commented Apr 3, 2026

Copy link
Copy Markdown

This PR is included in version 1.4.1

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.

1 participant