algorithmic modeling for Rhino
Hi david,
Here is a small annoyance in C# components, having a wrong index in .net list/array/collection always shows line 0 in the error message:
code:
List<object> testFailure = new List<object> ();
A = testFailure[3];
In this case finding the bug is trivial, but when dealing with dozens of lines of code it's a bit annoying, especially since it's one of the most occurring bugs.
A workaround for this problem is to wrap the code in a try catch, and rethrow the exception with a stack trace:
try {
List<object> testFailure = new List<object> ();
A = testFailure[3];
} catch (Exception e)
{
throw new Exception(String.Format("Exception: {0} Trace: {1}",e.Message, e.StackTrace);
}
Tags:
Thanks for this!
I got used to this error, and usually found the prob quite fast. But that's a great workaround.
Thanks.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by