All Questions
Tagged with exception error-handling
45 questions
0
votes
1
answer
160
views
Python exception for handling invalid argument types
Greetings
One small problem that anyone have to tackle with in Python is handling invalid argument types ( without an automatic static type checking tool like
Mypy )
One of the best methods for ...
2
votes
3
answers
178
views
Wrap a noexcept C++ library method with a method throwing exceptions with usable explanatory strings to stay DRY
In our apps we're using a shared inhouse library which provides filesystem functions. All the functions are noexcept.
In several apps i found that similar or identical error return translations are ...
3
votes
1
answer
210
views
Catching the timed out Exception raised by the __init__ method of the class ftplib.FTP
Introduction
I have written a Python class which uses the module ftplib. In this class I have created a private method called <...
1
vote
1
answer
161
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 ...
5
votes
1
answer
469
views
Write a simple, clean error message without a backtrace and exit on failure
I want to write on failure to either STDOUT or STDERR a clean, simple error message for the user, without the (verbose) ...
3
votes
1
answer
934
views
Class to wrap result or exception, similar to the OneOf approach
I recently came across the OneOf<T0,...,Tn> package from mcintyre321 via a video by Nick Chapsas, which presents the idea of holding exception types to be ...
6
votes
1
answer
213
views
Handling errors in potentially incomplete responses
I am using the library geoip2 to get Geolocation of many IP adderesses
...
5
votes
2
answers
2k
views
C++ custom exception class
I am wondering, how can I improve this simple MissingResource exception class? I am using it in my simple game.
...
1
vote
1
answer
214
views
Handling multiple try-catches in a for loop
Good day! I would like to know if this is possible to be refactored into a cleaner code.
The reason I'm doing it like this is to catch the column that the error appeared on and then potentially output ...
4
votes
2
answers
238
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
136
views
Is it good practice to use try catch only for a part of the code [closed]
When I submit the form, I need to validate the input data from an HTML form field, which comes from the user who submitted the data. So inside the Page_Load event, ...
1
vote
1
answer
57
views
Handling errors in an input based program
I wrote a program which creates a svg-group that contains several arranged rectangles with passages inbetween to reach all of the rectangles inside of an area selected by the user. Each rectangle ...
8
votes
2
answers
4k
views
See if a specific resource exists in a Kubernetes namespace
I want to have a function that checks to see if a certain resource (deployment, job, cronjob etc) exist in a namespace. Using the Kubernetes Python client, I can create a boolean function (using ...
1
vote
1
answer
72
views
5
votes
2
answers
4k
views
Custom C++ exception class with stack trace generation
I wanted to implement my own runtime error class in C++, that could provide more meaningful information on where the error occurred than std::runtime_error does.
I ...
1
vote
1
answer
199
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 :
...
10
votes
3
answers
7k
views
Prompting for two integers and dividing, using exceptions to handle divide-by-zero errors
I'm trying to learn exception handling in C++.
I wanted to read two integers and divide them and print them.
The code should throw an exception when the second integer is zero, ask the user to re-...
3
votes
1
answer
123
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 ...
3
votes
1
answer
238
views
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:
...
1
vote
1
answer
129
views
Python exception handling class - Getting as much details printed
I'm trying to write a Exception Handling class in Python so that I can re-use. If you have any ideas on how I can improve this to output more detailed information I would appreciate it:
...
3
votes
1
answer
660
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.
...
4
votes
1
answer
12k
views
AggregateException handling
How do you handle AggregateException? It is really useful in many TPL or business scenarios, but handling is a real pain. I defined the following three extensions ...
5
votes
2
answers
792
views
Throw an exception which contains a nested set of previous exceptions
I have a set of domain objects which try to find a solution to a problem.
The top level object has an algorithm which splits up the problem and delegates it to lower level objects, which in turn do ...
3
votes
1
answer
1k
views
Custom error/fatal error and exception handler in PHP
Introduction
I wrote three functions that aims to log errors and exceptions as well as show a user a generic error page. Would appreciate some feedback on it with regards to the PSR standards and if ...
8
votes
4
answers
604
views
C# PasswordService class
I am new to C# and develop a configurable PasswordService class. As the code works the next step is to improve the code.
Right now there are the following options:
...
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 ...
3
votes
2
answers
95
views
Handling exceptions and executing code if one was found
I have this code:
...
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 ...
1
vote
1
answer
923
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
2
answers
342
views
Python and Exception Handling IOError [closed]
I'm trying to work with exception handling by displaying "No Such File" when the file doesn't exist. I need to use a try statement.
...
4
votes
1
answer
284
views
Throw exception in favor of an error?
I've been reviewing my previous projects for the last few days. I've found that I never return an error from any of my methods. I always throw exceptions. I googled about exceptions vs errors and I ...
5
votes
3
answers
2k
views
How to chain exceptions?
I have some function like:
...
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
347
views
Rethrowing exception just as an information
I have something like that:
My custom exception class:
...
3
votes
1
answer
200
views
Compiler warning on unused exception...need to improve structure?
Consider the below:
...
5
votes
1
answer
13k
views
Accumulating inner exception messages
Say, there is a class with some methods, that have try catch blocks. I need to accumulate messages from all inner exceptions of generated exception and use ...
2
votes
1
answer
366
views
Suggestions for improving error handling [closed]
I am interested in finding out what is the correct way of implementing error handling for this situation in C#.
The system tries to do an operation. If the operation succeeded (returns a non-error ...
0
votes
1
answer
108
views
uplifitng return value error reporting to Exception based error reporting
In Framework Design guideline book there is a chapter about Exception and they talk about return-value-based error reporting and exception based error reporting and the fact that we in a O.O language ...
1
vote
1
answer
551
views
PHP - Is this proper use of exceptions for error handling within classes?
I've searched plenty on this topic and have gotten a lot of good (but different) results. Some of the results weren't quite related and it does seem to be a matter of preference in the end, but I'm ...
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:
...
19
votes
3
answers
13k
views
Generic C++ exception catch handler macro
I have this set of legacy C++ projects with a large number of public functions. At the start, none of those publicly exposed functions had try..catch insulation ...
4
votes
3
answers
866
views
Making a job completed, rolling back on error
I have the following construction in the program:
...
9
votes
5
answers
4k
views
Providing unchecked exception "wrapper" interfaces for an API with checked exceptions
I recently had a discussion in the forum of an API, because they changed an exception from checked to unchecked. I believed it needs to be checked, because it is recoverable. The arguments of "the ...