I am trying to add an unhandled exception handler in .net (c#) that should be as helpfull for the \'user\' as possible. The end users are mostly programers so they just need
I don't know a way to obtain the values of the arguments of each function in the call stack trace, but one solution would be to catch the specific exception (KeyNotFoundException
in your example) and re-throw it in a new Exception. That allows you associate any additional information you wish
For example:
Dim sKey as String = "some-key"
Dim sValue as String = String.Empty
Try
sValue = Dictionary(sKey)
Catch KeyEx As KeyNotFoundException
Throw New KeyNotFoundException("Class.Function() - Couldn't find [" & sKey & "]", KeyEx)
End Try
I appreciate your statement about localising the error strings, but if your audience are 'mostly programmers' then convention already dictates a comprehension of English to some degree (rightly or wrongly - but that's another debate!)