Questions tagged [exceptions]
An exception is an occurrence in an application process that requires deviation from the program's normal flow.
642 questions
5 votes
5 answers
590 views
Is it good practice to check exception messages in unit tests? [duplicate]
Imagine I have a function like this (written in Java): void sayHello(String firstName, String lastName) { if (firstName == null) { throw new IllegalArgumentException("first name is ...
4 votes
2 answers
503 views
Control flow and communication with two separate frontends (maybe with exceptions)?
I am trying to write a backend for use with a completely text based UI for one shot operations (eg. python scriptname arg, executes that argument and exits) and a GUI using the curses library for some ...
1 vote
4 answers
547 views
Combining multiple input validations into one exception
In order to make sure methods fail fast under invalid arguments, I usually do validation at the start of a method. If I'm verifying multiple predicates, this leads to a few lines of checkNotNull or ...
0 votes
2 answers
731 views
Explain why it's bad to use a middleware to coat error messages as exceptions
We manage a backend application behind a FastAPI REST controller with multiple endpoints. A member of our team decided to use a middleware on the application which parses the body of the response for ...
5 votes
6 answers
2k views
When to write a custom exception handler?
A long time ago I was in a class and the professor had us write individual exception handlers for every possible error. This seems almost impossible to do when developing large pieces of software ...
3 votes
1 answer
825 views
How to catch every exception in a multi-threaded C++ app with the minumum of code?
I have been tasked with the title above. There is currently zero exception handling. There are 100+ threads, all created from main(). Exceptions won't percolate up to main() - they won't leave the ...
0 votes
1 answer
306 views
How to correctly extend runtime exception?
We have a GraphQL server which sends data to the front end client. We have other tenants who will use our sever and host their code. I want to create a system where they all can create any custom ...
2 votes
1 answer
225 views
Is returning Result types the standard way of dealing with errors in Kotlin?
Given that there are no checked exceptions in Kotlin, are Result types the correct way to indicate an exception occurred to the caller? For example, I have the following function in my code: suspend ...