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.
4
votes
1answer
30 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
33 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
53 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
35 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
307 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
146 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
257 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
435 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
515 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
308 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
46 views
Exception-handling optimisation
I have posed another question here and I am writing this one for some code review:
...
1
vote
1answer
34 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
38 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
191 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
209 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
83 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:
...
2
votes
2answers
50 views
Java ClassNotFoundException Handling
Is there a better way to handle this ClassNotFoundException ?
...
1
vote
1answer
45 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
37 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
97 views
Check quotient and division by zero [closed]
Please evaluate this code and tell me if it is standard C++ coding:
...
5
votes
3answers
116 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
95 views
Exception Handling with `instanceOf` rather than `catch` [closed]
Would there be any reason to use the following code?
...
7
votes
1answer
454 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
38 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
457 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
141 views
4
votes
1answer
70 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
234 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
1k 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
93 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
174 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
42 views
Passing around Connection
I have a myCon=getUnusedConnection() method that gets a connection from Connection pool. I also have a ...
3
votes
1answer
169 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
116 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
84 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
131 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
161 views
Rethrowing exception just as an information
I have something like that:
My custom exception class:
...
2
votes
1answer
145 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
142 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 ...
1
vote
1answer
86 views
How to refactor this importer to handle validation errors?
This is my importer to database from excel file. I would like to handle situations when any error raise. To not breaks whole import when one errors occurs.
For example when there is duplicated record ...
3
votes
1answer
138 views
3
votes
2answers
1k views
Review of “is port in use?”
Review this code. It should return true if a port is in use, false if the port is not in use. Clarification : "In use" means ...
5
votes
1answer
1k views
Reducing cyclomatic complexity
I ran a sonar analysis on my code and it told me the cyclomatic complexity is too high (sonar's limit is ten branches).
Here is my code:
...
10
votes
3answers
1k views
Try-catch inside while(true)
I have a situation in which a program, communicating over the network, can timeout or otherwise fail to establish a connection through no fault of my application or its user. If and when this happens, ...
1
vote
2answers
623 views
A better way of checking if index is out of bounds
For a simple project, I represent a two-dimensional grid as a one-dimensional array, with both row and column indices between 1 and ...
1
vote
2answers
168 views
Exceptions to control data read flow
I previously posted a Reservoir-Sampling program, which was basically a test version of this one. This is an assignment. In the code below, I use RunTimeException ...
2
votes
1answer
351 views
Managing Data access layer exceptions
I am developing a webapp using Spring MVC + Hibernate. I created a GenericDao class that implements basic data access methods, to be extended by all my concrete daos in the app. What I want advice or ...
5
votes
2answers
182 views
Object can throw exception on construction, but I don't want it to stop everything
I have a factory that loads configuration from an xml file, and uses the configuration to be able to create objects of an appropriate type with appropriate settings. My application does a number of ...
0
votes
1answer
59 views
Dealing with resource closure when rethrowing an exception
I would like a review and recommendations for improvement of the code below. I want to allow an exception to be handled by the caller, so I am rethrowing it. But I have resources to close. So I ...