All Questions
Tagged with comparative-review error-handling
19
questions
2
votes
3
answers
693
views
Capture multiple errors before raising an exception
I have a scenario where I need to store values from some environment variables (names of which I cannot control). My first run at this was pretty basic, however this is not usable as an exception ...
3
votes
2
answers
370
views
Retry read/write until all bytes are transferred or error occurs
Currently I have a wrapper function for the read/write system calls, the purpose of which is to eliminate partial transfer ...
2
votes
1
answer
717
views
Go functions to create a directory if it doesn't exist
Which of the 2 solutions is written better? Personally I prefer the one line method but it does make it slightly more difficult to debug. Is perhaps doing it the long way first then refactoring to ...
5
votes
1
answer
151
views
Detecting the presence of multiple URL segments
I have two versions of a function that performs the same task, however I'm not sure which one to use. Speed is something to take into consideration, but I also want to know what the best practice is. ...
3
votes
1
answer
410
views
Given a list of words, remove the shorter word of every pair
This is not a "please do my homework" question. I solved a problem two ways and would like to know which solution is better; better being defined by better readability, lower complexity and lower ...
6
votes
1
answer
79
views
Return true from enumerable that calls function unless that function ever returns false
Is there a tighter way to write this code?
...
5
votes
3
answers
85
views
Four versions of a database-creation function with different error handling
I'm starting a new, small C project and would like to have the safest, cleanest and shortest error handling code possible.
Here is a comparison of different ways to handle errors in the same C ...
2
votes
4
answers
1k
views
Throwing exceptions if there is not exactly one box retrieved
(Note: this is originally posted as this SO question )
I'm trying to refactor the error logging and exception throwing into a method.
Original code:
...
2
votes
2
answers
633
views
Dict lookup with type conversion and fallback
Given the following working code:
...
6
votes
1
answer
49
views
Fetching lists and finding one with the right name, with fallback on error or no match
I have a simple function:
...
2
votes
2
answers
73
views
Controller method to validate and save
I have built RESTful web services. The services endpoints have a similar logic:
If the input validation succeeds, do a database operation and return the result.
If the db operation fails, return the ...
6
votes
1
answer
124
views
Avoiding code repetition while handling exceptions
For my application, I need to use two slightly different algorithms for persisting an entity:
...
2
votes
2
answers
1k
views
Root-finding by iterated bisection
Both of the following code give the same result. But I'm not sure where should I put the raise statement.
...
2
votes
1
answer
88
views
Two error-reporting conventions for a command-parser
I need to implement some function and I would like to report about a fail made inside a function. If function doesn't fail I need to get a some result (for example, ...
6
votes
4
answers
2k
views
Checking errors from a series of function calls
I have to work with C-style functions which return ERROR_SUCCESS when successful or an error code when not. I want my code to be nice and neat and easy to read but ...