Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution.

learn more… | top users | synonyms

0
votes
1answer
18 views

Showing a JDialog whenever there is an exception

I have made a method which I use to show the exception error through a JDialog window whenever there is one in my program. For now I can pass it either a String or ...
4
votes
2answers
218 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 ...
3
votes
1answer
70 views

Creation of a temp file on Windows

I implemented a test that reads data from temp file on Windows. I originally had an issue that I solved with the help of this answer ...
3
votes
2answers
48 views
3
votes
1answer
37 views

Idiomatic catching of unchecked exceptions in ExecutorService.submit

OK, here's the problem space: Lwjgl, a graphical library, has the ability to throw an unchecked LWJGLException on certain methods - like ...
2
votes
0answers
38 views

Rails app that scrapes forum using Nokogiri gem

I've built a website that scrapes a guitar forum's pages and populates Rails model. I'm using rake task along with heroku scheduler to run background scrapes every hour. On the homepage, the forum ads ...
10
votes
4answers
1k views

Send email just once per day

I want to send an email just once per day. There is one button and any user can click that button. The email must not be sent twice. When the first user clicks the button, the email is sent. If ...
2
votes
1answer
135 views
2
votes
0answers
44 views

Pausing a SwingWorker with a Timer

I made a SwingWorker which is fetching tweets using the twitter4j API. The twitter API will allow 180 queries every 15 minutes, and then throw an exception with ...
7
votes
2answers
81 views

Exception handling for HTTP request timer

This method is used to check a URL and return the time it takes to check and the HTTP status code: ...
3
votes
1answer
56 views

Throwing an exception within a try/catch block in PHP

Is there a cleaner way to do this? ...
6
votes
2answers
75 views

Retry loop for asynchronous HTTP requests

I've got a method that needs to PUT data to a web API. Sometimes the connection fails, so I needed a way to do retries, but if the retries fail, I still need to capture the exception and re-throw it. ...
7
votes
4answers
1k views

Dice-rolling program

I am sort of new to programming. I would like to understand the code areas that are garbage and could be better written keeping the exact (if possible) behavior the code has now. ...
7
votes
3answers
363 views

Handling exceptions for providing log information while debugging

I am catching exceptions to provide better information for the logs to make debugging easier in production. I was wondering if this code follows best practices as I'm not really handling the error ...
3
votes
1answer
49 views

Selenium Java: errorRecovery

I have the following code to select an image using Selenium, only now I have added an errorRecovery. Is there is a better way to right the code in the ...
8
votes
3answers
106 views

Validation/error handling of user input values

This is a tiny learning program that lead to an interesting question: how can I best/most elegantly handle user entered numbers? This method works, fails cleanly, and reads well. It doesn't apply to ...
5
votes
3answers
759 views

Class for catching error and logging

I often write something like this in my code: ...
2
votes
1answer
131 views

Simple Operations Calculator

I'm practicing Swing effects. Everything works but for some reason I get a ton of error messages in the command prompt when the fields are empty, despite my attempt to add some exception handling ...
1
vote
1answer
78 views

Is this acceptable usage of try/catch and database transactions?

I am using try/catch syntax in combination with a database transaction to (hopefully) prevent partial registrations. I am ...
4
votes
1answer
57 views

Improvements to nsiZipReader and nsIScriptableInputStream

I wrote this code to list contents of an XPI file and then read the contents in it. I was thinking areas of improvment: I put the zr.open in the ...
2
votes
2answers
51 views

Branching with multiple Try

I have a series of four method calls that all return Try[Something], with the last returning Try[Unit]. Something like this: ...
5
votes
1answer
147 views

Verifying the type of an AggregateException's inner exception in a unit test

I've got the following code inside an integration test. ...
3
votes
1answer
52 views

JSON fetcher for Eclipse plugin — Is this exemplary code for exception handling?

I am planning to use this code as a "good exception handling" code example in one of my papers. It is for a client module of an Eclipse plugin. How does it look? ...
3
votes
1answer
73 views

Exception handling with expression lambda in Presenter class

Following is a code snippet from MVP Win Forms application. My DAL doesn't handle exceptions and it will be propagated up to the calling method in the presenter classes where the exception will be ...
4
votes
1answer
50 views

Follow Up post: Proper handling of exceptions in MVP

This is a follow up post of my early question "Proper handling of exceptions in MVP" So based on the answers I re edited the post and now my exception handling code looks like this... DAL ...
6
votes
2answers
325 views

Proper handling of exceptions in MVP

In my DAL currently I'm handling exceptions as follows. Is it in an acceptable level? Note : I'm using MVP in this Winforms application. ...
6
votes
2answers
208 views

Will this Circuit Breaker catch fire?

I was going to post this code as an answer to a recent question, but I wrote this code a little while ago (like, a year ago; if I recall correctly I wrote this after reading this article) and I'd like ...
7
votes
3answers
270 views

Scrubbing user input

I'm taking user input from a file in form (1, 2, 3) to create a color, and I just wanted to know if I was taking most cases into account, and if there is any way I ...
7
votes
1answer
448 views

Is it bad when my code is throwing exceptions, but doesn't crash during runtime?

Here's part of code in Java for battleships game I'm working on: ...
14
votes
2answers
556 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 ...
7
votes
2answers
375 views

proper way of handling exception while reading user input from file

I am parsing a text file (UTF-8) and checking for several conditions that need to be satisfied for the code to be happy. If not, then there is no point to continue and the program should die. At the ...
0
votes
1answer
55 views

Exception-handling optimisation

I have posed another question here and I am writing this one for some code review: ...
1
vote
1answer
45 views

How to add exceptions in a class that reads a config file?

I am using Boost for reading a config file that is in the .json format. I am using a class to do this and I am calling exit(message) in case of bad values or ...
2
votes
1answer
55 views

Python script to find large folders

I wrote this script a few days ago to find all files which were taking up over a certain threshold of memory on the hard drive. A hard drive on one of my computers had just 6 GB left, so I needed to ...
4
votes
2answers
199 views

Exceptions or something else?

I'm in the process of creating a program that can model points, vectors, lines and segments. I have the classes built and confirmed to be working correctly. The classes are built to handle multiple ...
11
votes
1answer
318 views

Variant class with full move support

I tried to write my own variant class, that is fully move-semantics enabled. WRT to implemented visitors, they don't require any policy and like to be derived from ...
6
votes
2answers
90 views

Searching for files in a specified directory

I am currently writing a program that allows me to search for files in a user-specified directory. My current code is as follows: ...
6
votes
1answer
6k views

Reading data from Excel sheet with ExcelDataReader

Objective: I want to import an Excel file, and read the rows of certain columns. For this, I use ExcelDataReader. I've implemented a low-level class called ...
2
votes
2answers
60 views

Java ClassNotFoundException Handling

Is there a better way to handle this ClassNotFoundException ? ...
1
vote
1answer
56 views

Compute logistic regression on tweet objects

Is my approach good to naming variables and exception handling? I would like to make this code more robust and maintainable. I need advice on exception handling, var naming and comments. ...
0
votes
1answer
56 views

Class for connecting to mongodb databases and return collection object

This code connects to a mongodb database and returns collection objects. I am concerned about the exception handling, variable names and comments. ...
5
votes
3answers
143 views

StoredErrorWriter

Functionality that overwrite standard error message with trace to user friendly message with error number stored in DB. Not yet completed some stuff with trx... Please review this. DB table: ...
0
votes
1answer
215 views

Exception Handling with `instanceOf` rather than `catch` [closed]

Would there be any reason to use the following code? ...
7
votes
1answer
474 views

Dividing 2 numbers

The problem is to input, divide 2 ints and display the result. Please, review my program. It worth noting, I've intentionally used ...
3
votes
2answers
44 views

How to reformat this code so I don't use 'Exit Try' and 'Exit For'?

I use SonarQube to help me try and become a better programmer to program along with 'best-practice' standards. There are business rules when a user is submitting data they enter in a datagridview ...
5
votes
2answers
49 views

Proper action when a Java program fails

I have a program that has to initialize a few big things (connect to a few databases, parse some XML) and without the initialization being successful the program would not be able to continue. Right ...
5
votes
3answers
468 views

Should this be written with exception handling instead of nested if-thens?

I have a function that iterates through a list of file updates, and for each file, if updates are needed, download the file from the server, make the updates, and upload the updated version. Each ...
5
votes
3answers
185 views

How to chain exceptions?

I have some function like: ...
4
votes
1answer
87 views

Simple helper method for JUnit3 tests

In JUnit 3, I cannot tell JUnit what type of exception is expected. In JUnit 4, the ...
7
votes
3answers
346 views

Simple MPG calculator in Python

I am a self taught coder taking a Programming Fundamentals class to work towards a degree. It's based on Python, which I'm not as familiar with as other languages. I added error handling like I would ...