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
183 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 ...
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 ...
0 votes
1 answer
172 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;...
2 votes
4 answers
494 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 ...
0 votes
2 answers
107 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 ...
1 vote
2 answers
281 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 ...
0 votes
1 answer
594 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, ...
0 votes
1 answer
217 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, ...