Tag Info

New answers tagged

1

Depending on your problem and if there is a chance, you are running on linux,I can recommend using strace. There is a nice video. In general it is a low level tool revealing the systemcalls a monitored process does. To trace child processes, there is the option to follow those with -f. A typical call would be strace -p 1234 -f -e file -s 9999. That monitors ...


1

Your best chance would be to run the application with a debugger and set a breakpoint on that line (or the constructor of ConfusingException). Edit: It is possible to set a break point even in 3rd part applications when source may be unavailable. As in this case in the method or ConfusingException as suggested here.


1

I agree with remaining answer on one fact : That "exceptional return" does happen and needs to be handled. But reason why exceptions exist is not that exceptional returns exist. It is possible to have "return values" for each of the possible error states, just like C does. The reason why exceptions are preferable to C-like error handling is that it is ...


1

Because it is more readable code. For example (i love examples): function myFunc(someInput:String) : OutputType if firstErrorCondition(someInput) throw new FirstConditionException if secondErrorCondition(someInput) throw new SecondConditionException if thirdErrorCondition(someInput) throw new ThirdConditionException // do some other ...


0

Remember first you are solving problems. Imagine a simple solution, adding two numbers. You should do the following. Code the successful path in a test first. Ie. given 2, 2 return 4, given 1,2 return 3 and so on. Write the code to pass the test. Figure out ways to break things. Ie Given 1 raise exception Not enough args, Given A, 3 raise exception ...


8

Because exceptions (as opposed to error code return values) cannot be ignored. The typical code for i/o calls before exceptions, was usually written in terms of printf/scanf/gets/puts. These functions return values that allow the developer to check for errors, but that is not trivial. Most developers, knowing the error handling is not trivial, simply ...


-1

I find exceptions are cleaner for code style since I can wrap the code and deal with any errors in a specific location (the catch block), as opposed to littering my code with lots of if statements (if (result == -1)), to check for error conditions.


-6

Behavioral Economics #101: because it's the easier way. Exceptions are, in part, an acknowledgement that error-handling is hard and while we can recover from exceptions, it's much easier not to. Exceptions are the programmer's way of saying "I have this ideal situation that must be matched and I'll not bother spending more lines nor time handling ...


18

Because input and output are unreliable. Exceptions are, in part, an acknowledgement that there are going to be conditions which the software cannot reasonably recover from. Premature end-of-line termination, syntax error or any number of validation error conditions, Inputs are too long or large to reasonably accomodate, Keyboard gets unplugged, Hard ...


0

As you pointed out, often the specifics of what constitutes invalid request parameters is different enough for each view, and so including this type of code in each view is (I think) fine and not a DRY violation. It also self-documents the view by having code at the beginning that clarifies what the view expects to receive, either in the URL, GET, or POST, ...


3

Ultimately, it depends on the specification of the particular language that you are using, but in general, pass-by-value-result (Wikipedia) means that the original value of the caller will not be modified until the function returns, so the only reasonable thing to expect is that the value should remain unchanged in the event of an exception, because when an ...


0

In some cases a nested Try-Catch is unavoidable. For instance when the error recovery code itself can throw and exception. But in order to improve the readability of the code you can always extract the nested block into a method of its own. Check out this blog post for more examples on nested Try-Catch-Finally blocks.



Top 50 recent answers are included