Skip to main content

All Questions

Filter by
Sorted by
Tagged with
5 votes
1 answer
898 views

I'm working on a Scala project and Wartremover shows an error about Option#get usage in my code: Option#get is disabled - use Option#fold instead While I do understand how get should often be avoided,...
Cedric Reichenbach's user avatar
4 votes
2 answers
312 views

Amongst other things in my life, I'm writing a framework in PHP to manage a slew of common problems I come up against in every project I tackle. The framework is currently very data-centric, with the ...
e_i_pi's user avatar
  • 899
11 votes
5 answers
2k views

I'm struggling with a very simple question: I'm now working on a server application, and I need to invent a hierarchy for the exceptions (some exceptions already exist, but a general framework is ...
Dominique's user avatar
  • 1,844
-1 votes
3 answers
589 views

I am learning Python and when I learned that we can build Custom classes for exception, I got into a confusion of Why ? for example1 : class MyException(Exception): def __init__(self, error): ...
Yogi's user avatar
  • 21
-1 votes
1 answer
1k views

I came across a tutorial which says this code is Exception Ducking public class SomeClass { void doTask() { try { //..Some Exception prone code } catch(Exception e) { } }} ...
Salim Shamim's user avatar
6 votes
8 answers
7k views

From Effective Java 2e by Joshua Bloch, An example of the sort of situation where it might be appropriate to ignore an exception is when closing a FileInputStream. You haven’t changed the state of ...
Max's user avatar
  • 267
24 votes
10 answers
6k views

I often come across methods/functions which have an additional boolean parameter which controls whether an exception is thrown on failure, or null is returned. There are already discussions about ...
donquixote's user avatar
3 votes
2 answers
788 views

Problem I wonder what best practices are to indicate implementation errors detected at runtime. For example, if you write the following method (in Java): public void doSth(int i) { try { ...
user905686's user avatar
8 votes
2 answers
4k views

Given an onion architecture, what are the advantages and disadvantages of throwing exceptions in the business logic (which is in the center of the onion) for invalid parameters provided by the user? ...
Flavius's user avatar
  • 257
-1 votes
1 answer
351 views

Do Special Case or Null Object design patterns still provide value when application behavior, not just object behavior has to change? I was tasked with revisiting an old application and refactoring ...
PieMaker's user avatar
1 vote
1 answer
127 views

When I use the Exception provided by the SPL the options are limited. So it's hard to pick which exception would be best suited to handle File exceptions. I know the best scenario is to write my own ...
Giel Berkers's user avatar
1 vote
2 answers
2k views

I have a try/catch block which looks like this : try { geoms.add(convertLineToGeom(ln)); } catch(IllegalArgumentException e) { System.out.println("ligne n°" + counter + " : " + e.getMessage())...
Paul Lemarchand's user avatar
1 vote
1 answer
227 views

I know that often catching all exceptions (C#: catch(Exception exception){...}) is deemed bad practice. However, I believe that there are situations where it is perfectly reasonable to do it. For ...
Gerino's user avatar
  • 481
1 vote
2 answers
275 views

I recently asked a question on SO where I was trying to understand how to catch an exception in a piece of code which runs indefinitely. I was initially expecting that try: ...
WoJ's user avatar
  • 1,661
-1 votes
1 answer
3k views

I'm just designing the exception handling for the REST interface on our Spring server. As we will have multiple REST controllers, a central exception handling is desired. Spring offers the solution ...
Herr Derb's user avatar
  • 439
-1 votes
1 answer
77 views

I am working on a ReST based service which calls other ReST based services and also deals with Persistence in a database. So a typical call might look like Get some data from the database. Make a call ...
Venkat Dabri's user avatar
11 votes
2 answers
4k views

Let's say I have an interface describing a simple service public interface AccountService { public int getUserId(String userName) throws UserNotFoundException; //... } I've written the ...
Winter's user avatar
  • 705
4 votes
2 answers
288 views

Assume that I wish to perform an action on a string (e.g., print the string) if, and only if, the string first passes several tests. The tests are diverse (and may even be complex functions themselves)...
Michael Gruenstaeudl's user avatar
33 votes
3 answers
6k views

The problem: Since long time, I am worried about the exceptions mechanism, because I feel it does not really resolve what it should. CLAIM: There are long debates outside about this topic, and most ...
Adrian Maire's user avatar
38 votes
4 answers
23k views

I'm reading "Learning Python" and have come across the following: User-defined exceptions can also signal nonerror conditions. For instance, a search routine can be coded to raise an exception ...
J B's user avatar
  • 489
2 votes
4 answers
774 views

I just started working on a new project and no one throws exceptions over here. I get that you shouldn't be doing that for asynchronous code, but it seems to be a valid way to do things for the ...
unflores's user avatar
  • 402
5 votes
4 answers
9k views

State machines, for example UML state machines, statecharts or other finite state machines, allow actions to be executed when a state machine takes a transition between states or is within a state. ...
user avatar
3 votes
2 answers
2k views

The application this question is about is basically a transpiler which contains a lot of logic. The transpiler is written in C++ (which should not be much of relevance for this question), and it ...
leemes's user avatar
  • 139
10 votes
1 answer
750 views

It is a widely held position that checked exceptions as implemented in Java are a bad idea. If you mark a method as throwing, calling code has to either catch the exception, or be marked as throwing, ...
jdm's user avatar
  • 632
0 votes
2 answers
185 views

What is the commonly accepted enterprise standard for Exception management? Consider the project has three layer structure. - Controller - Service throws ServiceException - Dao throws DaoException ...
Arun's user avatar
  • 119
3 votes
2 answers
341 views

While trying to debug a weird issue where I knew an exception should have been thrown but was not, I found the following in the Java standard library's java.lang.ClassLoader class: /** * Open for ...
Ellie Harper's user avatar
7 votes
2 answers
1k views

I have the following situation. I'm writing a c++ program where I have a function that checks a custom equivalence of two json objects. If the check fails, I don't want the entire program to stop (...
Krupip's user avatar
  • 1,347
1 vote
2 answers
2k views

I have my multi module maven project with the following structure: + parent - pom.xml + model - persistents - dao - model stuff... - pom.xml + service - services - services ...
CodeSniffer's user avatar
78 votes
14 answers
19k views

Ever tried to sum up all numbers from 1 to 2,000,000 in your favorite programming language? The result is easy to calculate manually: 2,000,001,000,000, which some 900 times larger than the maximum ...
Bernhard Hiller's user avatar
1 vote
5 answers
1k views

In our code base, I see a lot of code like this var error = ValidatePhoneNumber(userId, phoneNumber); //if validation fails, return error if(!string.IsNullOrEmpty(error)) { return error; } If I ...
Microsoft Excel's user avatar
1 vote
4 answers
4k views

I'm writing a library which will be a base for a turn-based battle system but i don't know what are the best practices for exception handling, has anybody some advice for me? Should I catch every ...
arabum97's user avatar
4 votes
5 answers
3k views

What is the better way to organize exception in a Python project? What is the right way to use exception description? For example I have a function that parse email and return some data from it's ...
Yann's user avatar
  • 583
11 votes
2 answers
13k views

As I try to deal with the possibility of failure when I invoke RESTful endpoints or in general any HTTP endpoint I've been wondering if there is any standard or pattern in the HTTP specification or in ...
edalorzo's user avatar
  • 2,696
13 votes
4 answers
10k views

I have a bunch of classes which deal with validation of values. For instance, a RangeValidator class checks whether a value is within the specified range. Every validator class contains two methods: ...
Arseni Mourzenko's user avatar
3 votes
6 answers
368 views

There are cases where I don't know how to use exception handling. To make it clear, let me divide exceptions into two types: exceptional cases that may happen occasionally, such as when you try to ...
Mehrin's user avatar
  • 37
0 votes
4 answers
5k views

This is a specific question here, but I'm interested in the general "best practice" for similar situations as I'm new to Java. Suppose I have Java code that needs to open a file (see below for code). ...
Johnathan's user avatar
6 votes
2 answers
707 views

I'm developing a Ruby on Rails app. The app contains a service wrapping an external REST API, called from a controller, with several possible error states. The current implementation returns the ...
jacwah's user avatar
  • 395
3 votes
1 answer
1k views

I have a piece of code parsing a text file line by line. I have to goals: Testing the syntax of the text and extracting information of it. It is quite likely that syntax errors occur so I want to ...
Semjon Mössinger's user avatar
7 votes
4 answers
429 views

Observation There are many Exception subtypes that don't have any added state or behavior. For example, ClosedByInterruptException code. Question Why is subtyping without adding state or behavior "...
Dioxin's user avatar
  • 953
112 votes
13 answers
12k views

I'm developing a library intended for public release. It contains various methods for operating on sets of objects - generating, inspecting, partitioning and projecting the sets into new forms. In ...
anaximander's user avatar
  • 2,295
5 votes
4 answers
2k views

This year I started using several Third-Party-Libraries (all open source) and I noted that some throw exceptions in a proper way (i.e. declaring exactly which checked Exceptions can be thrown by a ...
GreenThor's user avatar
  • 201
4 votes
1 answer
140 views

What changes need to be made to a language/runtime if one wants to implement fully asynchronous exceptions (thrown from one thread to another, capable of interrupting pure computation without the need ...
Martin's user avatar
  • 149
24 votes
4 answers
12k views

Everytime I need to provide additional information about an exception I wonder which way is actually the right way of doing this. For the sake of this question I wrote an example. Let's assume there ...
t3chb0t's user avatar
  • 2,601
33 votes
5 answers
4k views

I'm trying to convince my team lead to allow using exceptions in C++ instead of returning a bool isSuccessful or an enum with the error code. However, I can't counter this criticism of his. Consider ...
DBedrenko's user avatar
  • 571
6 votes
2 answers
4k views

So I wanted to know the differences between these two. I know software interrupts are sometimes referred to as exceptions, which makes the differences between the two somewhat confusing. Asking this ...
sbhzi's user avatar
  • 169
1 vote
1 answer
546 views

I have read this and this and this: if my question misses the point in those answers, please point it out and we'll get this one deleted. These questions indicate that this may actually be a bad thing ...
user58446's user avatar
  • 327
5 votes
0 answers
134 views

So in a relatively famous blog post, Eric Lippert categorizes exceptions as lethal, vexing, bone-headed, and exogenous. He defines vexing exceptions as ones created by unfortunate design decisions and ...
Jared Smith's user avatar
  • 1,935
2 votes
3 answers
2k views

The codebase I work with has a certain pattern prevalent in all public methods, which goes like this: public void UpdateUser(User userArg) { Framework.NullCheck(userArg); var user = userDb....
Frayt's user avatar
  • 281
3 votes
2 answers
3k views

Why do some Java methods throw exceptions that are subclasses of another exception that they also throw? One example is org.apache.commons.httpclient.HttpClient.executeMethod(HttpMethod method). It ...
amphibient's user avatar
  • 1,591
3 votes
1 answer
1k views

So I've been programming for a few years mostly as an amateur/student, and I'm aware of the fact that using exceptions is generally frowned upon when used as a lack of consideration for input and just ...
Nick's user avatar
  • 141

1 2 3
4
5
13