Skip to main content

All Questions

0 votes
2 answers
322 views

Is it bad to use checked exceptions as API response?

Consider the following code: public class User { private String password; public void changePassword( String oldPassword, String newPassword) throws ...
George Z.'s user avatar
  • 705
1 vote
2 answers
163 views

Is passing an ErrorMessage to be populated inside the receiving method an anti-pattern?

I come from a Java background, and my colleague is from .NET. We are working on a Java project and I saw him create a method like this: public Object myMethod(Object[] param1, ErrorMessage ...
lemuel's user avatar
  • 131
0 votes
2 answers
421 views

Throwing custom exceptions in library: do I throw concrete ones or their superclass?

I am designing a library that abstracts a typical CRUD http service named FooService. In this library I am throwing different exceptions like FooServiceClientException for network related errors or ...
Carlos Campderrós's user avatar
1 vote
3 answers
678 views

Should a file reader library API throw exceptions?

I am developing a (Java) library providing an API to read a file in a specific format into an object. The format is basically a map, and specifies valid values for some of the keys, and valid types ...
s.d's user avatar
  • 243
35 votes
5 answers
51k views

Function returning true/false vs. void when succeeding and throwing an exception when failing

I'm building an API, a function that uploads a file. This function will return nothing/void if the file was uploaded correctly and throws an exception when there was some problem. Why an exception ...
Accollativo's user avatar
10 votes
2 answers
3k views

Why are checked vs. unchecked exceptions called “the controversy” in Oracle Java tutorial?

I am new to Java and was reading its documentation on exceptions., and especially the Unchecked Exceptions — The Controversy page. The bottom-line says: If a client can reasonably be expected to ...
ABcDexter's user avatar
  • 209