How to edit properties within an existing Exception? (Message, StackTrace, etc)

Hey everyone! I’m trying to figure out how to edit the properties of an existing exception.

Example: newException = new Exception(“This is a test”)
Looking up newException.Message results in “This is a test”
Add to the message " and this is new"
Looking up newException.Message results in “This is a test and this is new”

How do I add to this while preserving the other properties of this exception? When I try defining it, I get this error:
image

I specifically want to be able to edit the Message and the StackTrace properties of an exception, but open to learning about changing other properties too.

It’s probably not writable. You’d have to store it in a variable and then update in the variable.

Seems it isn’t possible. See eg. this discussion in StackOverflow (C#, but still relevant): .net - How to change exception message of Exception object? - Stack Overflow

May I ask why you want to do this?

Well shucks, thanks for trying though!

I’m using a library that injects specific exception details in an email, but the library is written to accept the exception as an argument and then parse that information within the library. I’m trying to add additional information into the exception to help identify which queue item had issues and specific troubleshooting details to make it easier than having to look elsewhere.

@geneddie

Those details you can add to the exception data field and then when writing it somewhere you can access that data firld to get the info and append it when needed instead of modifying the message

Excep.Data("Key") = "value you want to append"

Data is like a dictionary so you can use it later by using the key you added…may be something liek extra_message

Cheers

You can try this:

Exception variable is io_SystemException

Use Assign Activity and save to this variable:

new System.Exception("Error101")

This will change the Message property of the exception variable.