Skip to main content

All Questions

4 votes
2 answers
434 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 ...
Hugo Schongin's user avatar
3 votes
3 answers
386 views

How to handle checked exceptions on interface contract in Java

I am starting a project in Java and ran into the following situation. The application requires a persistence layer for a certain document type. This could be a MySql database, an AWS Dynamo DB ...
Matias Grioni's user avatar
1 vote
4 answers
349 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 ...
EarthTurtle's user avatar
4 votes
5 answers
3k views

The best way to handle exceptions?

I have the following method, which needs to return a List, but exceptions might occur along the way, and I don't want to handle them in my application, mainly because I don't even know how to handle ...
MasterTJ123's user avatar
0 votes
2 answers
602 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 ...
Blue_Elephant's user avatar
5 votes
7 answers
480 views

Exceptions and the Liskov Substitution Principle

Consider the following scenario. I have an interface IService: public interface IService { void DoSomething(); } with an implementation: public class Implementation : IService { // This might ...
Codisattva's user avatar
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 ...
FourierFlux's user avatar
1 vote
5 answers
210 views

End method in normal flow versus exception flow

Consider the two following examples: public Something fetchSomething(String key) { if(somethingsMap.containsKey(key)) { return somethingsMap.get(key); } throw new ...
steros's user avatar
  • 121
3 votes
1 answer
690 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 ...
Mawg's user avatar
  • 4,262
1 vote
2 answers
2k views

Exception Handling in Hexagonal Architecture

how could we advise the web client about a non-recoverable exception thrown by the persistence adapter ? At first sight, I would define a domain exception to be thrown by the persistence adapter and ...
hjoly's user avatar
  • 21
0 votes
1 answer
265 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 ...
user415612's user avatar
0 votes
1 answer
114 views

Return response from controller or raise exception from service

I need some guidance on how to send error responses to client from WebAPI controller for an update operation. I need to check if data is changed and if it has duplicate data. I have service class that ...
Sunny's user avatar
  • 945
2 votes
1 answer
188 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 ...
Adam's user avatar
  • 272
-2 votes
3 answers
746 views

Locally throw exception and handle it

I came across a piece of legacy code, almost on the line of this (sample) int foo() { try { int id = generateID(); if (isIDUsed(id)) throw id; return id; } catch (int ...
Zoso's user avatar
  • 241
0 votes
2 answers
617 views

Is Authentication a good use case for a checked exception according to Effective Java (Bloch)?

There's a section about use of checked exceptions in Josh Bloch Effective Java and I find it a bit abstract to understand what he means by saying "when a user can recover from it". ...
TMOTTM's user avatar
  • 109

15 30 50 per page
1
2 3 4 5
43