Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [exception]

An exception is a rarely occurring (exceptional!) condition that requires deviation from the program's normal flow.

-1
votes
0answers
25 views

Count the number of occurrences of each symbol in a string array

This calculates the number of occurrences of each symbol in a string array. I want to find some places in this multithreading code which could lead to a NullPointerException or other exceptions or ...
5
votes
1answer
54 views

Game asset manager

I've been using Monogame for hobby game development for the last year now. My game assets aren't large so I usually load them all on startup. I would have a static AssetManager class with a ...
1
vote
1answer
44 views
5
votes
2answers
496 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 ...
0
votes
1answer
53 views

Using a wrapper on a primitive as a generic for an interface used for Java lambda

I apologize for that title, lol. I have a Java method that I'm writing where I want to be able to pass in an array of Objects and two interfaces that will be used for lambda expressions that specify ...
4
votes
2answers
104 views

Automatic exception wrapper in java

There's a lot of place in my code where I need to do something like this ...
5
votes
1answer
555 views

C++ Read istream into string with exceptions

Did I cover all the bases? Can this be improved (best practice)? Edit... I've come up with some improvements. When I tried edit the code, the software complained about too much code and too little ...
1
vote
0answers
48 views

Exception handling with recurrency

I writing application that collect job offers from few websites and tries to apply for each joboffer using implementation of this interface for each website: ...
2
votes
1answer
73 views

Class hierarchy for informative exceptions in ASP.NET core

I have a base class called ExceptionPlus(please suggest a better name). Which is being inherited by multiple child class like BusinessNotFoundException, ArgumentInvalidException etc. My question is ...
2
votes
1answer
63 views

Getting single element or throwing one of two exceptions

Sometimes I need to get a single thing from a collection but I'm not very happy with the Single extension. It does not differentiate between empty and more than one ...
3
votes
1answer
102 views

Custom exceptions for validating movie information

I wrote my first application about custom exceptions and catching them. Here is the GitHub link. I Have 3 types of custom exceptions: TimeException (validate time: hours, minutes) MovieException (...
2
votes
1answer
1k views

Creating data objects dynamically at runtime from an interface

Sometimes when I write objects for holding data (not real DTOs, no serialization involved) I also create an interface for it. The class that implements it can also perform some null checks. I don't ...
3
votes
1answer
110 views

Compiling and throwing simple dynamic excepitons at runtime

I often need a simple exception with a meaningful name and some helpful message which usually just look like this one: ...
7
votes
2answers
409 views

Validation for a CQS system that throws an exception

I've been reading that exceptions should only be for something "exceptional" and not used to control the flow of a program. However, with a CQS implementation, this seems impossible unless I start ...
1
vote
1answer
75 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
1answer
4k views

C++ custom exception design

I have a custom exception hierarchy in C++ to detect unexpected cases in a library I am implementing. The base exception class inherits from std::exception and all ...
10
votes
3answers
4k 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-...
5
votes
1answer
746 views

Generating unique ID of an exception

For classifying error reports, I need to generate an ID from an exception. That ID should be (more or less) unique a short alpha numeric string equal for equivalent exceptions (even on different ...
5
votes
3answers
3k views

Custom exception for string that is too long

This is my first time working with Java exceptions. I have made a program that works to specifications, but I am wondering if there is anything I've done which is unconventional or not recommended. ...
3
votes
2answers
375 views

ExceptionPrettifier for prettier exception strings

I've been refining my previous idea for pretty exception strings and made the following changes: Exceptions can be ordered. Prints all properties including Data. ...
1
vote
2answers
858 views

Hackerrank Inherited Code

I'm back at it again with an Hackerrank challenge-Inherited Code . I just learnt exception and I thought it will be a great idea to get a second opinion on my implemented ...
4
votes
2answers
264 views

Catching exception inside model

Is it normal to catch exception in concept of MVVM inside model? Or how should it be? How to improve this code? This is simple application that allows user to drop .pfx certificate on the label. <...
2
votes
0answers
155 views

Checking authentication status by looking for a cookie

I'm an Android newbie. I have this function in my code: ...
3
votes
1answer
76 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
1answer
138 views
1
vote
1answer
2k views

Custom Exception.ToString() formatter

I find the default Exception.ToString() formattig very difficult to read especially if there are inner exceptions involved. I guess everyone knows how it looks: <...
2
votes
4answers
186 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: ...
0
votes
1answer
311 views

Count check before Linq Single() call

Should I check Count before Linq Single() call if I expect only one element? ...
2
votes
1answer
164 views

Extended exception for network errors in Python

I need a custom exception for network errors that holds a related exception and more than one URL (the first one as the used service has its URL but it indirectly calls other URLs), so I wrote this: <...
1
vote
1answer
92 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: ...
4
votes
2answers
3k views

DAO to create, update, and delete a project

I'm trying to write my first "complex" program in Java. So far, I created a local H2 database but I'm not sure about the quality of my code (I'm newbie in Java) because I don't know how I can deal ...
3
votes
1answer
220 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 ...
1
vote
1answer
42 views

Pretty handling FileNotFoundException

I have got a piece of code that initialize Scanner in two possible ways: no argument constructor creates Scanner that uses stdIO (System.in) as source contructor with String, which creates Scanner, ...
2
votes
1answer
504 views

Retrieving access token from SharedPreference

Here is code that retrieves an access token from SharedPreference. ...
4
votes
1answer
3k 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 ...
0
votes
1answer
212 views

Custom Exceptions based off the Visual Studio snippet

I'm creating my own application exception types so I could catch them higher in the call stack and take specific action. I'm looking to get feedback on the latest exception I've written for two ...
1
vote
1answer
707 views

Function to validate parameter and throw exception when invalid

I've asked a question receiving excessive (in a good sense) feedback. After I've incorporated it into the code, it changed substantially and I felt that I'd need opinion on the new version. Posting ...
5
votes
2answers
474 views

“Better” Exception with autogenerated message

Because I don't like writing the same useless exeption messages all the time ;-) I thought I create a better exception that would make this for me. This is what I came up with: ...
4
votes
2answers
237 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
1answer
888 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 ...
7
votes
1answer
930 views

Cancellable futures, interaction with throwing destructors

I'm reinventing std::future from scratch (for an upcoming talk). I'd like to incorporate as many of the latest and most likely-to-succeed proposals as possible, and ...
1
vote
1answer
218 views

Working with Exceptions Exercise

The task: There is an AccountManager that makes transfers. It receives 2 arrays of the same size: accounts and sums. They need to be transferred to the accounts ...
1
vote
2answers
5k views

Parsing double from string

I'm trying to parse Double from String in Java. The string input is not necessarily a number, any non number input should be ...
7
votes
2answers
100 views

A closed exception system

I am working on yet another toy project that I named SGL (for "Standard Generic Library" since it mimics some features of C++'s STL as well as a few more utilities from the C++ standard library). ...
8
votes
4answers
526 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: ...
1
vote
3answers
36 views

Managing batch runs of Fortran programs

I have a program which basically manages batch runs of some underlying Fortran programs, and at the end, I want to move all the related files into a different directory. At the moment, there is ...
2
votes
0answers
68 views

Extending Exceptions with module-specific prefix, intended for parsing error reporting [on hold]

For one of my [WIP] project, I extended the dictionary class a lot with specific handlers, as such I determined that I wanted KeyError and ...
8
votes
2answers
1k views

Customized Exception

I am building my "base exception to end all base exceptions" class in C# and was looking for some opinions on my implementations so far. Ideally my usage of integrated Rethrow, Throw, and ThrowFatal ...
3
votes
1answer
4k views

Checking if a directory exists in FTP without relying on exception handling

I've written a method to check if a directory already exists on an FTP server. The only way I could see to make this work was to return a different result from the method if an exception is thrown - ...
1
vote
2answers
84 views

Simple interface and class for holding text to be analyzed

I am making a sentiment analysis library targeted first at social media text (like Twitter) and then I will expand it for more general use. For the first step I am making a simple interface and a ...