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

3
votes
1answer
33 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 ...
0
votes
0answers
26 views

Whats the best approach to report exceptions to the caller? [on hold]

I have the following code that return integer values to report type of the raised exception to the caller of the method and eventually user of the application. I suppose it is not the best way to do ...
8
votes
3answers
55 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
738 views

Class for catching error and logging

I often write something like this in my code: ...
1
vote
1answer
69 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
66 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
43 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 ...
1
vote
0answers
17 views

What kind of exception to ask for out of range arguments? [migrated]

What type of exception should I throw? I have a console class which describes rectangle of cells which a user can index by passing in a coordinate: ...
2
votes
2answers
35 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
62 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
40 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
57 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
43 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
319 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
157 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
259 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
443 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
529 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
327 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
49 views

Exception-handling optimisation

I have posed another question here and I am writing this one for some code review: ...
1
vote
1answer
39 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
41 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
194 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
228 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
84 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
2k 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
54 views

Java ClassNotFoundException Handling

Is there a better way to handle this ClassNotFoundException ? ...
1
vote
1answer
52 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
50 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. ...
3
votes
2answers
101 views

Check quotient and division by zero [closed]

Please evaluate this code and tell me if it is standard C++ coding: ...
5
votes
3answers
123 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
122 views

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

Would there be any reason to use the following code? ...
7
votes
1answer
458 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
40 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
46 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
463 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
155 views

How to chain exceptions?

I have some function like: ...
4
votes
1answer
75 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
247 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 ...
20
votes
3answers
2k views

Java method - levels of abstraction

In his Clean Code book, Robert C. Martin states that functions should do only one thing and one should not mix different levels of abstraction. So I started wondering whether the code below meets ...
3
votes
1answer
95 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
1answer
182 views

Code to construct a complete graph

I have tried to design a class for a complete graph. Needless to say, disadvantages of my current solution are very visible: dependent inputs have led to verification headaches. In this code we ...
3
votes
1answer
43 views

Passing around Connection

I have a myCon=getUnusedConnection() method that gets a connection from Connection pool. I also have a ...
3
votes
1answer
175 views

Is there any way to make this function, which takes char*, exception-proof?

I should preface this question by saying that I'm a Java programmer working on my first C++ application, so perhaps there are certain obvious things I don't know. Some background on the problem: Our ...
1
vote
2answers
121 views

What's better: return null or handle the Exception?

I'm in doubts what approach to take here, please have a look on the code below: ...
2
votes
1answer
87 views

Review of approach to inheriting from std::exception [closed]

I would like a review and recommendations for improvement of my approach to resuing std::exception. Just a quick justification for the four constructor arguments: I want to force myself to always ...
7
votes
3answers
132 views

Exceptions handling, what would you do?

I know that there are several ways to handle exceptions and probably a good way is to keep the handling consistently and use the pattern which feels comfortable for himself, but I would like to get ...
5
votes
1answer
170 views

Rethrowing exception just as an information

I have something like that: My custom exception class: ...
2
votes
1answer
161 views

Exception Handling Design

I am trying to design an exception hierarchy for logging errors. These logs will be used only by developers and not by users. This is a base class that I came up with. ...
1
vote
1answer
157 views

Exception based on std::exception but easy to modify and rethrow

I've looked at boost::exception and realized it is too advanced for my project, as my colleagues mostly have legacy C background. I do not need arbitrarily complex ...