Questions tagged [error-handling]
Questions related to handling errors and exceptions. According to Wikipedia, Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional events requiring special processing – often changing the normal flow of program execution. It is provided by specialized programming language constructs or computer hardware mechanisms.
308 questions
2
votes
3
answers
191
views
API Design: Should I explicitly check for and throw on nullptr parameters if I have full control?
Say I have the following header
#ifndef WINDOW_HPP
#define WINDOW_HPP
// includes...
namespace window
{
struct Window
{
GLFWwindow *handle = nullptr;
};
struct ...
2
votes
8
answers
1k
views
Fail fast is brittle
I am creating a CSV consumer (with Java). There is one field / column that should contain one of the values "Rename" or "Move".
I implemented this by allowing mixed case of letters,...
29
votes
14
answers
11k
views
Avoiding throw because we are not sure the exceptions will always be caught
I'm a junior in my company, and one of the coding rules they have is:
"a constructor object must never fail" (i.e., never throw). So what if I give them an invalid parameter? Then, the ...
-3
votes
2
answers
819
views
Is throwing an error in programming is good Idea at all? [duplicate]
I am wondering if throwing an error in programming is good Idea at all ?
While programming we throw error when something unexpected or invalid has occurred. But if we have thrown exception and it is ...
0
votes
1
answer
174
views
Error codes in a legacy C++ project [closed]
Background
I have a large C++ project which uses system error codes from errno.h, in C style.
int Cls::foo(A arg, O* out) {
if (!validate(arg)) return -EINVAL;
if (!out) return -EINVAL;
return 0;...
1
vote
2
answers
145
views
CQRS how to display failed commands in the GUI
I am trying to use CQRS in my project and I was thinking how the GUI gets notified about failures in the GUI, when commands are fire and forget. My commandhandlers are not returning anything, but ...
2
votes
4
answers
498
views
Watchdog/recovery mechanism for realtime embedded system (using heartbeat, exceptions and Posix signals)?
We have a large(ish) real-time embedded system. It's VxWorks, if that makes any difference. It has some C code in DKMs, but is 95%+ in C++.
It has absolutely no exception handling, nor Posix signal ...
5
votes
2
answers
2k
views
C#: Refactoring an oversized try/catch/finally
Recently I've come to discover that I've inherited one of the internal auxilliary programs used. I've made a few minor fixes and features to improve it in the past, but now I've been given a major ...
0
votes
2
answers
108
views
Deserializing serial protocol enums: Recoverable or unrecoverable errors?
I am currently implementing a library in Rust that implements a proprietary serial protocol.
The protocol specifies several enum values, that mostly are returned by the hardware as u8s (bytes), but ...
0
votes
1
answer
101
views
Communicating unpredicted Failure from Repository implementation to Applicaiton Layer
My application follows Clean Architecture wherein the Application Layer wraps the Domain Layer. I try to adhere to DDD more-so as a "guiding light" than a strict rulebook.
Within the Domain ...
1
vote
2
answers
288
views
Choosing a strategy for representing and handling errors (or more generally status codes) in java 8
I asked this questions on StackOverflow but it's definitely a bit too broad.
Even for this website, although the question is about software design, it might not be enough "focused".
I am ...
3
votes
2
answers
3k
views
Standard error codes vs custom error codes in C
I am working on improving the code quality and portability of my C library, specifically a ring buffer implementation, that will be used in larger applications. I have encountered a dilemma regarding ...
0
votes
1
answer
596
views
HTTP error 404 or 500 from an internal call to a separate API?
I have an endpoint in API 1 (my api) that queries API 2 (another companies api) to view and edit objects stored in API 2's database. API 1 is essentially acting as a wrapper service around API 2, ...
1
vote
1
answer
498
views
How to E2E test handling of an unknown error in a client-server application?
Using a ton of libraries, IO, ... you cannot handle all imaginary errors.
You will need some form of "catch uncaught exception" handling to still have a control flow for such a case.
But if ...
0
votes
1
answer
218
views
Bubbling errors upstream in async message-based services
Imagine a simple set up of an API and a 2nd service, where the API pushes some msgs to the message queue and the service pulls them and processes them.
Now, if an error occurs while processing a msg, ...