27
votes
Accepted
C# TCP server/client class
Networking
You have done the classic thing that all people new to TCP do of assuming that whatever NetworkStream.Read gives you will be some meaningful chunk of ...
23
votes
Accepted
Custom error-logging
Reusable methods
Notice that you have several methods that essentially do the same thing. Log and both writeCustomErrorLog ...
17
votes
Accepted
A simple error messaging and logging system via macro(s) in C++
You’ve already noted that this could be done better without macros, so I won’t belabour the point. I will note, though, that your goal—“to refresh [your] skills at writing good solid macros”—makes ...
15
votes
Accepted
How much error handling is too much?
Let's start with a code review. Your style is pleasant with good naming and indentation. About the only thing I would suggest is that method RetrieveFoobar could ...
15
votes
Accepted
Robust error handling mechanism in C++ (safer than std::expected)
Design review
Your design description has a number of factual errors and misunderstandings in it, and more than a little questionable reasoning, all of which undermines the design of ...
14
votes
Accepted
ASP.NET REST controller with try-catch error handling
throw ex;
This is a fatal mistake. It'll create a new stack-trace and you won't be able to tell where the actual exception occured. If you want to rethrow it then ...
14
votes
Accepted
Heap implementation for numeric types
Memory management
You never delete[] arr;, which leaks memory. Not a good thing! There are multiple ways to fix this:
Adding correct calls to ...
12
votes
Accepted
Decoding assembly instructions in a Game Boy disassembler
I have some ideas about how you might be able to improve your program.
Avoid problems
Rather than trying to deal with the problem for every instruction, one approach is avoiding it entirely. One ...
12
votes
Dividing two numbers then handle the divide by zero exception with try/catch
If you know that you want to divide two numbers then IMHO it would make more sense to perform a pre-liminary check.
In other words, rather than executing the operation "blindly" by trusting ...
11
votes
Accepted
Compiling all Exception messages into a string
Readability first
I've tried to condense everything to one line, but am unsure if this is the most efficient way of approaching this problem.
Your primary goal when writing code is readability and ...
11
votes
Accepted
Go function to test whether a file exists
Instead of checking with an if statement if errStat is null and then returning false:
...
11
votes
C# TCP server/client class
Review
This review handles readability metrics and C# conventions only and should provide insights to reach some of your goals.
Goals: learn C#, improve coding style, create good to read code
There ...
11
votes
Accepted
Python implementation of atoi
Python already has an exception that denotes that the value you passed is inappropriate somehow. It is ValueError, which is what the built-in ...
11
votes
Robust program to write an array of certain data type to a binary file and read back from it (C++17)
using namespace std;
Don't do using namespace std;. It can lead to name collisions and other issues.
Typing out the full names (...
10
votes
Accepted
An exception-safe wrapper for std::stoi
This wrapper effectively removes some of the available functionality from std::stoi() because its signature is
...
10
votes
Accepted
Skipping over failed imports until they are needed (if ever)
There is one issue with your approach which is, in the case of multiple import failure, only the last one can be properly reported:
...
10
votes
How much error handling is too much?
If the function is central to your application then it's perfectly normal to have extensive error handling, compared to the rest of the code.
In practice the amount of error handling is dictated by ...
9
votes
Accepted
Setter error checking
Input validation is a critical aspect of any reliable program. Your code is functional, but there are a few things to note.
First up, the RuntimeException is not a ...
9
votes
Accepted
Should my Json storage handle exceptions?
This is how I see things...
Throwing ArgumentException insinde a try/catch that at the same time swollows it is pointless. You ...
9
votes
Accepted
Error solution: Uncaught TypeError
Does this open up the possibility for any buggy behavior that I don't know about?
It's not likely to. The if statement is fine, though it can be made cleaner:
...
9
votes
How much error handling is too much?
Reduce your error handling to a single line.
When you have any code where you are following the same basic format a lot like this to the point it makes your code too verbose for your own personal ...
9
votes
Basic scoped timer struct design
I don't see why m_end is a member, as it's unassigned for the object's entire life, and only meaningful within the destructor. I would make it a local variable ...
9
votes
Accepted
Dividing two numbers then handle the divide by zero exception with try/catch
If you need a repetition either use a recursive call or a loop. In this situation a loop makes sense.
...
9
votes
Robust error handling mechanism in C++ (safer than std::expected)
Your class does make sure the DataFunction is only called if there is actually Data stored in the variant. However, it suffers ...
9
votes
Python Exception Monitor
It's likely to be irrelevant for most parameters, but I think that self.nb_calls += 1 belongs in the try block before calling ...
8
votes
Recording error messages from an exception
In C# 6 or later you can write it in a single line of code using the null conditional operator (?.) and the null coalescing operator (...
8
votes
Accepted
Error-Handling Class and Logging for VBA
Amount of boilerplate code
As it is, there are lot of boilerplate that we must provide to set up everything. At a minimum, we need the following code:
...
8
votes
An exception-safe wrapper for std::stoi
int _stoi(std::string str, int* p_value) {
Identifiers that begins with an underscore is reserved to the implementation for use as a name in the global namespace.
...
8
votes
Network helper class with retry logic on failure
Just wanted to add that you may want to consider using Polly instead of rolling your own retry mechanism - this is a library built specifically for this kind of retry mechanism (as well as many more ...
8
votes
Accepted
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
error-handling × 838c# × 163
java × 158
python × 109
c++ × 86
beginner × 57
javascript × 51
php × 51
exception × 47
c × 46
python-3.x × 41
vba × 34
http × 30
logging × 29
object-oriented × 27
file × 27
performance × 26
excel × 24
node.js × 20
validation × 20
asynchronous × 20
.net × 19
comparative-review × 19
io × 19
ruby × 18