I recently started using underscore.js and love it a lot. I see lots of benefits from it, but I have seen one glaring caveat that I want to report.
When an exception occurs in the handler passed to the _.forEach function, the stack trace gets broken, i.e. it does go all the way to the exact cause of exception. This makes debugging the code really difficult.
Fortunately I could figure out why this happens and have a potential solution. In the forEach implementation, you have a try-catch block where you catch the exception thrown by the application handler, you check it against breaker and if it is not breaker then you throw it again. This is the statement at which the stack trace ends, and it never reaches the actual statement (which is in application code). I removed that try-catch and that fixed the stack trace.
I understand you use breaker to implement the breakloop function call. I personally don't use it, I don't know about others. I feel the broken stack trace is a more important issue than the breakloop functionality.
Can this be fixed? One possible solution is to remove that try-catch and find alternative way to implement breakLoop().
I recently started using underscore.js and love it a lot. I see lots of benefits from it, but I have seen one glaring caveat that I want to report.
When an exception occurs in the handler passed to the _.forEach function, the stack trace gets broken, i.e. it does go all the way to the exact cause of exception. This makes debugging the code really difficult.
Fortunately I could figure out why this happens and have a potential solution. In the forEach implementation, you have a try-catch block where you catch the exception thrown by the application handler, you check it against breaker and if it is not breaker then you throw it again. This is the statement at which the stack trace ends, and it never reaches the actual statement (which is in application code). I removed that try-catch and that fixed the stack trace.
I understand you use breaker to implement the breakloop function call. I personally don't use it, I don't know about others. I feel the broken stack trace is a more important issue than the breakloop functionality.
Can this be fixed? One possible solution is to remove that try-catch and find alternative way to implement breakLoop().
Thanks.