Questions related to handling errors and exceptions. According to Wikipedia, Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional events requiring special processing – often changing the normal flow of program execution. It ...

learn more… | top users | synonyms

0
votes
1answer
33 views

How to do error management in a web development team?

What are some good practices to do error management in a web application of about 30 people divided into 5 people team, where each team is responsible of a specific part of the application? I am ...
2
votes
1answer
118 views

Where do you print IO error messages from in a console app?

I'm writing a simple console app to rename a bunch of files/folders, and I want to design this console app to be as modular as possible. The console app is as simple as it gets: Ask the user what ...
2
votes
3answers
243 views

Why do assertions in Java need to get enabled?

I really like the concept of assertions in Java in the way how to use them. It's much easier than to write an if and then throw an Exception/Error. But the thing I don't understand is, why do they ...
2
votes
1answer
129 views

What are the limitations of Java exception approach to errors?

Please ignore performance issues, I am interesting in data flow, safety, modelling, reasoning. I wonder what are the limitations of exception approach to error reporting implemented like in Java ...
0
votes
3answers
81 views

Preventing information leakage while returning an error message

Say my website contains 2 functions: Allow a user to change their own password Allow an administrator to change a user's password (the user must change again before they login) Now let's say that ...
11
votes
5answers
403 views

Is indiscriminately catching exceptions (Pokemon exception handling) ever acceptable? [duplicate]

Normally, I don't anticipate exceptions and if I get them, its something that I can't fix in my code - bad user input or connectivity issues with the database. But errors do occur so at the very ...
0
votes
0answers
22 views

Handling error with Promise

I'm writing a small application in TypeScript that has to do some asynchronous operation and I'm doing it with Promise and async/await sugar. But my problem do not rely on the particular language or ...
7
votes
2answers
126 views

How to work with/around an API that does not return errors?

I am currently working on a project which requires data fetching from a 3rd party closed API (over SOAP). Currently I'm in a situation where I have to do argument and data validation inside our ...
1
vote
1answer
103 views

Standalone library for error logging?

Background Here is how I currently log any exceptions that occur in my code: Pass each object instance the path to a file where I want all of the logging to happen. Each of the objects have their ...
2
votes
1answer
25 views

Handling and reporting errors consistently

Errors can come from many different sources - third-party services, libraries, environment, etc. When an error prevents a user from performing their desired action, these diverse errors should be ...
2
votes
2answers
90 views

Java EE exceptions for validation and APMs

In my current work, we have some Java EE applications and we use exceptions and exception mappers to deal with user errors, i.e. that can't be dealt with in the frontend. We usually reply with a 400, ...
1
vote
1answer
81 views

Error handlers inside Promise.all

I'm looking at this piece of code and whilst it works, it feels wrong to me. I'm wondering if I am looking at an anti-pattern? The code starts with two promises, getAccounts and getTransactions. On ...
4
votes
1answer
121 views

Overflow Exception Checking Problem

Background I have to call a method that needs to return a signed integer (see code block below) after converting from an unsigned integer. The reason for this is that I have to do bit-wise math that ...
-2
votes
1answer
97 views

Investigating in a highly distributed environment [closed]

I was asked this by an interviewer today and unfortunately he wouldn't share the kind of answer he was looking for so I'm hoping maybe the community can help. Say you're an engineer at company X and ...
53
votes
5answers
7k views

Will a computer attempt to divide by zero?

We all know 0/0 is Undefined and returns an error if I were to put it into a calculator, and if I were to create a program (in C at least) the OS would terminate it when I try to divide by zero. But ...
35
votes
7answers
4k views

Arguments against error suppression

I've found a piece of code like this in one of our projects: SomeClass QueryServer(string args) { try { return SomeClass.Parse(_server.Query(args)); } ...
1
vote
1answer
86 views

Recieving errors without engaging in excessive communication when using sockets

I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of ...
2
votes
2answers
320 views

Error handling in C++

So, in the recent weeks I delved into C++ programming, and I programmed some things in SDL. Doing so, you always have to deal with a lot of (ugly) C++ code, which looks more like C than C++. One thing ...
1
vote
2answers
98 views

Load to list in one loop and then process list in another or do it all at once

I have a dataset full of rows that I must initialize into myclass and then process. I am currently looping through each row in the dataset, initializing a new instance of myclass, then adding that ...
0
votes
2answers
99 views

Should I log errors in the function they occur? or pass them back and log them when control returns?

One of the things I love about Go is how they encourage passing errors as return values, but when it comes to logging what is the most maintainable solution: passing the error as far back down the ...
2
votes
5answers
348 views

Handling null-references in C# logic

Let's say I have an API method with can be used to calculate the sum of all orders made by a specific customer: Amount CalculateOrderSum(int customerId) { // Perform authentication to make sure ...
3
votes
3answers
179 views

Are exceptions only for handling errors?

I have a script that throws exceptions when something goes wrong. However, for the purposes of testing I also want to capture specific points although I'm not sure whether they would be deemed errors ...
27
votes
3answers
1k views

Should I use HTTP status codes to describe application level events

Several servers I have dealt with will return HTTP 200 for requests that the client ought to consider a failure, with something like 'success : false' in the body. This does not seem like a proper ...
3
votes
1answer
30 views

How to design error monitoring for batch jobs with multiple and diverse steps?

I'm working on a software to integrate an e-commerce store and the company ERP. All the integration steps are run as a unique batch job, every 5 minutes. Things are working under production, but I'm ...
-3
votes
2answers
228 views

Why ever use exception throw (in C#) except for Class Library development? [duplicate]

Why would I ever throw exceptions in code? (except for one specific scenario where I am developing a class library which the consumers of it, will not want / be able to change). To be more specific, ...
8
votes
2answers
444 views

Is the strong exception safety guarantee with a pass-by-value argument which can throw on destruction possible?

Suppose you have a type with a throwing destructor, and a function receiving it by value. Can that operation ever provide anything better than the basic exception guarantee? Or formulated differently, ...
53
votes
7answers
4k views

Should one check for every little error in C? [duplicate]

As a good programmer one should write robust codes that will handle every single outcome of his program. However, almost all functions from the C library will return 0 or -1 or NULL when there's an ...
4
votes
1answer
136 views

How to approach syntax errors when developing a lexical analyser?

I am writing an interpreted domain-specific language for my application. Each statement is parsed and executed as soon as lexical analyser decides that the end of statement is reached. It's handling ...
1
vote
1answer
157 views

How often should I use try/catch statements? [duplicate]

Everything I've read says that they should be used when something that simply "shouldn't happen" does happen. But the thing is, there's a lot of things that could go wrong. For example, if I'm ...
3
votes
1answer
249 views

Best practice for angular service return value

I have a number of angular services (e.g. a user service) which make various HTTP calls and I'm wondering what the best practice would be for handling errors. For example, I could do: function ...
0
votes
0answers
107 views

Test for PHP Errors using Browser Emulator (Mink)

I want to know the most robust way of checking for PHP error messages when running automated tests that interact with a PHP application via a browser emulator. The reason is: I use Behat, Mink and ...
0
votes
0answers
63 views

Checking for null pointers or allowing a math library to segfault?

I've been going through the GNU GSL design document and came across this interesting line in the Test suites section: N.B. Don't bother to test for null pointers -- it's sufficient for the library ...
4
votes
1answer
206 views

Should a web service return an error message if it receives unknown parameters?

I have a web service which allows to retrieve users: http://example.com/users. It returns a list of users. That service accepts a number of parameters (age, gender) to select which users to retrieve. ...
4
votes
5answers
2k views

Checking array size in C/C++ to avoid segmentation faults

So it's well known that C does not have any array bounds checking when accessing memory. Nowadays, if you call myArray[7] when you initialised it as int myArray[3], your program will get a segfault ...
1
vote
1answer
96 views

Should I put stack trace in error files and halt my app with user friendly error [closed]

In my earlier project I wrote an app that is used in-house. My usual practice is to capture errors/exceptions from different classes and threads and put them in different log files corresponding to ...
3
votes
3answers
123 views

Is this a valid situation for returning rather than throwing an exception?

This is not something I would ever normally do, but I have a situation where some existing legacy code is being reused in a new application. The code is shared and needs to be used by both the legacy ...
0
votes
1answer
48 views

Error handling in math library functions

When writing a library function, such as double getAvg(double[]); how should one handle the empty array? (Note that, mathematically speaking the avg of an empty set is undefined.)
8
votes
2answers
251 views

Do we need to validate entire module usage or just arguments of public methods?

I've heard that it is recommended to validate arguments of public methods: Should one check for null if he does not expect null? Should a method validate its parameters? MSDN - CA1062: Validate ...
4
votes
2answers
471 views

Rust-style error handling in C++

I've been reading some articles on how Rust does error handling using the Result<T, E> type and to me it seems like a hybrid best-of-both-worlds (exceptions and return codes) solution which can ...
2
votes
1answer
41 views

Storing exception information as a member variable for query later, bad practice? [duplicate]

I looking at the best way to handle exceptions, the answer to this question may be to handle the exception in a different place or to not handle to exception at all but to control the flow of the code....
2
votes
4answers
426 views

Design Pattern for retry and error handling

I'm trying to find a good design pattern, or perhaps series of patterns, for injecting error handling and retry handling when getting data from a webservice. For instance, I have: do { //get the ...
4
votes
2answers
220 views

Strategies to analyze collected exceptions

We want to add error feedback to our application. I had a look at existing solutions (e.g. raygun.io), but these work "in the cloud", which is a no-go for us: most installations of our application ...
1
vote
2answers
177 views

When writing a library or an API, when should and when shouldn't I validate or automatically correct errors in data provided by another developer?

I have a fairly good understanding of when data validation should and shouldn't exist when it comes when writing an application that is only dealt with by an end-user, and all the different tiers of ...
0
votes
1answer
134 views

Code Inside Catch Block

This question is related to both of these questions - Efficient try / catch block usage? and Dealing with error in data - Idempotent approach. When I encounter a void while reading a GIS data file I ...
6
votes
2answers
764 views

Designing exception classes

I'm coding a small library and I'm having some trouble with designing the exception handling. I must say that I am (still) confused by this feature of the C++ language and I tried to read as much as ...
5
votes
2answers
899 views

Should I always return an error code from C functions?

I have the following code in many places in a large application: if (datastruct.data_ok && cur_time > datastruct.start_time && cur_time < datastruct.end_time) { ...
0
votes
2answers
169 views

Catch unusual exceptions on production code for web apps

Lets say I have a web app, and despite my best testing efforts, several of the many thousands of people who uses it will find some way to generate an exception. Sure, I have error handling code for my ...
0
votes
4answers
63 views

Testing generic errors

I've got a program that validates it's input, and then errors. So far for each kind of error I created a new derived class. But this was getting pretty unwieldy (the input is complex so there are ...
1
vote
3answers
232 views

Protect memory from a potentially seg faulting function call

How can one safely call a function that might segfault without corrupting the stack or the heap? These SO questions cover using signal handlers and setjmp.h to regain control. Coming back to life ...
2
votes
4answers
112 views

What an application should do when there is an error notifying the user of an error?

Say I have an application, and it writes (among other things) errors to a log file. It's the first place the user would be asked to go and look if there was a problem. Let's also assume that this is a ...