All Questions
16 questions
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. ...
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 ...
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 ...
2
votes
1
answer
81
views
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 :
...
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 ...
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:
...
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 ...
2
votes
1
answer
1k
views
Retrieving access token from SharedPreference
Here is code that retrieves an access token from SharedPreference.
...
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 ...
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 ...
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:
...
5
votes
1
answer
358
views
Rethrowing exception just as an information
I have something like that:
My custom exception class:
...
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:
...
4
votes
3
answers
885
views
Making a job completed, rolling back on error
I have the following construction in the program:
...