Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
3 answers
180 views

Java exceptions that show the message when converted to String

I’m working with custom exceptions in Java for stack operations. However, I’m unsure if the exception handling is being handled properly, especially in terms of how exceptions are thrown and caught. ...
Somesh Diwan's user avatar
2 votes
1 answer
171 views

Beginner Java Tic-Tac-Toe

I had a Tic Tac Toe assignment for class and the program seems to work fine but I feel like the exception/input handling could be done in a much better way. Is this a good way to approach the ...
Drosos-kal's user avatar
4 votes
2 answers
239 views

Reader for graph-file with ugly return and questionable use of streams

I wrote a class that contains a static method that reads in files from NetworkRepository and converts them into a list of integer-arrays, each representing an edge. The file format from ...
Moritz Groß's user avatar
2 votes
1 answer
81 views

Exception handling with null check in java

...
Hyeonseo Yang's user avatar
1 vote
1 answer
204 views

Is it a valid use case of using java.util.MissingResourceException?

I have a factory method that returns an Object based on a argument passed to it : ...
Innocuous's user avatar
3 votes
1 answer
126 views

Command sequence executor with error handling

I've recently learned that as a Java developer my methods throw exceptions way too often, even when the reason for throwing is related to a business rule, when returning an error code instead could ...
Piovezan's user avatar
  • 267
2 votes
4 answers
1k views

Throwing exceptions if there is not exactly one box retrieved

(Note: this is originally posted as this SO question ) I'm trying to refactor the error logging and exception throwing into a method. Original code: ...
XoXo's user avatar
  • 185
4 votes
1 answer
667 views

Using a Boolean method that never returns "false" to check user permissions

I need to check that a user is allowed to save/retrieve contacts to/from the database by calling a web service, and return an HTTP403 with an explanation if it is not the case. So for the sake of ...
Anas's user avatar
  • 153
2 votes
1 answer
1k views

Retrieving access token from SharedPreference

Here is code that retrieves an access token from SharedPreference. ...
Vsevolod Poletaev's user avatar
5 votes
2 answers
1k views

Simple factorial program using recursion

Two concepts I realized I needed to understand and use more are recursion and Exceptions. Thus, I combined both in the following program. Although it began with a focus on using recursion it became ...
Legato's user avatar
  • 9,919
16 votes
2 answers
5k views

Using finally with return statement or not

I was wondering if it is the proper way to always put the return statement of a function with a try-catch clause in the finally ...
Aki K's user avatar
  • 1,329
4 votes
1 answer
10k views

Throw an exception to control the flow of code execution

There is a recommendation not to use an Exception to control the flow of execution. This gives me a reason for doubt when I do something like this: ...
Eugene's user avatar
  • 203
5 votes
1 answer
358 views

Rethrowing exception just as an information

I have something like that: My custom exception class: ...
radekEm's user avatar
  • 934
3 votes
3 answers
15k views

Exception handling continuing the excecution

This code is for continuing the execution after an exception, and this is ugly: ...
Hernán Eche's user avatar
4 votes
3 answers
885 views

Making a job completed, rolling back on error

I have the following construction in the program: ...
Vladislav Rastrusny's user avatar

15 30 50 per page