The various techniques used for maintaining stable program state in circumstances that, if not taken care of ("handled"), could cause serious issues, including logical bugs and abrupt execution termination.

learn more… | top users | synonyms

12
votes
6answers
1k views

Is wrapping exceptions good practice?

I have recently been refactoring some code in an effort to improve the exception handling, particularly to aid in improving the level of information given to developers during development. However I ...
1
vote
1answer
40 views

Mongoose promise & error handling

I search for rails-like way of writing NodeJS code and it's more then hard to find the right way. The code quickly become bloated and unreadable. I would like my code to be as clean as possible. ...
3
votes
2answers
42 views

Haskell monad- and error-handling-style

As an answer to excersise 2.3 in Chris Okasaki's book, Purely Functional Data Structures, Inserting an existing element into a binary search tree copies the entire search path even though the ...
0
votes
1answer
53 views

Nested try/catch with PDO in PHP

I would like to know if this is the correct way to use try/catch when dealing with multiple MySQL queries and PDO: ...
0
votes
1answer
21 views

Showing a JDialog whenever there is an exception

I have made a method which I use to show the exception error through a JDialog window whenever there is one in my program. For now I can pass it either a String or ...
11
votes
4answers
768 views

Writing null-safe code to set form values

I will ask my question using the following example: HTML ...
1
vote
1answer
21 views

Error-handling in Django model-adding form

I am writing a book database, and ultimately a library system, in Django. When a book is created without a title set, the ISBN will be used to automatically fetch book data from WorldCat I have just ...
10
votes
3answers
643 views

Returning status codes from business layer

This is what I've been doing so far in my business layer to return error messages to the user. ...
4
votes
3answers
173 views

Error-handling / Self-Validating mechanism

The below idea seemed to look clean, to allow the object itself to validate its values for different scenarios. For eg: While creating the object, the value of Object1 and Object2 in ...
6
votes
2answers
306 views

Generic error message factory

The purpose of this code is to centralize all error / status messages to present to the user. For example, registering an account and the user email address is already registered. A status code is set ...
0
votes
0answers
47 views

Mini eCommerce Application and Message/Warning/Error Handling

I decided to build a basic eCommerce application in C++ as a learning experience. In the past, I've gone with a fat controller, skinny model approach, and while it has worked, my results always end up ...
2
votes
1answer
159 views

Error Handling - Controller's OnException and Application_Error

I'm pretty new to MVC. Below is the code that I have added to an existing MVC 5 application. The code is using log4net to log any run-time error/exception. NOTE: I could override ...
7
votes
3answers
124 views

Creating check parameter class instead of repetitive null checks

What I'm trying to accomplish is to have a error checking class mostly to check if parameters that are pass null but also data structures within class are not null. So my thought is a clean static ...
4
votes
1answer
49 views

If vs try/catch

The following code, written in synchronous Node.js and intended to be used as a shell script, nests a try/catch inside a conditional. Because both the conditional and the try/catch serve a similar ...
4
votes
2answers
143 views

Game framework using C++

I'm writing my own game framework and would like to get feedback on the API while I'm writing it. At the moment it's very simple, but I would like some guidance about where to take it. This is a ...
4
votes
1answer
52 views

Using quickCheck for “99 Haskell problems” - problem 1

I'm working on learning Haskell, and I've implemented a solution to the first of the 99 Haskell problems. Here is my code: ...
4
votes
2answers
212 views

PHP and MySQLi login script - is it secure / am I doing something wrong?

Below is the code for my login page. I haven't really used MySQL (especially OOP) before, so I'd like to know if I'm doing something inherently wrong. The code is working as expected, but I don't ...
14
votes
8answers
1k views

Console application for providing detailed error messages

I'm writing a console application where I need to provide detailed error messages in case anything goes wrong. As a result of this, I find myself splitting up my code into many pieces and making sure ...
8
votes
2answers
147 views

Better option than “errno” for file IO error handling

I have the following method for opening a file: ...
4
votes
1answer
84 views

Simple way to prevent duplicate logging of errors

I've been tasked with updating our current error logging system to prevent the logging of similar errors (from a single client program) that were probably caused by the same event. The code here is ...
2
votes
2answers
95 views

Error Handling When Using Dictionary

I have set up a Dictionary that calls on a class to fill a DataGridView via SQL statements. The problem is in two (out of 5) ...
5
votes
2answers
74 views

Outputting Fractions

This program is to return a number one at a time from a given input list of numbers, with a frequency proportional to probability/fraction associated with each number. I know it could be made a ...
2
votes
2answers
225 views

Checking empty object

Is there a better method for covering errors in my case? I am looking for best practice for now and future instances. Foreseen errors that could arise: No attributes at all Some attributes could be ...
7
votes
1answer
207 views

Extending the VBA Extensibility Library

The Microsoft Visual Basic for Applications Extensibility library let's us meta-program VBA, but the way it handles (or rather, doesn't handle) getting to the actual subs and functions is clunky at ...
7
votes
1answer
113 views

File reader/writer (text)

Following-up on this post, I wanted to be able to use my FileWriter with a syntax reminiscent of .net's using blocks, which ...
7
votes
3answers
89 views

FileWriter supporting writing to multiple files

I got bored with opening and closing files whenever I need to write to one, so I wrote a FileWriter class that's used like this: ...
2
votes
0answers
86 views

Parsing a website

Following is the code I wrote to download the information of different items in a page. I have one main website which has links to different items. I parse this main page to get the list. This is ...
6
votes
4answers
151 views

What is a good way to check errors from a series of function calls?

I have to work with C style functions which return ERROR_SUCCESS when successful, otherwise return an error code. I want my code to be nice and neat and easy to ...
2
votes
2answers
799 views

Program simulating dictionary using file handling

I have made a program in C++ simulating a dictionary with very basic functionality. I do not have much experience in file handling with C++. Also, I want it to run on Linux and Windows. It would be ...
4
votes
2answers
79 views

Executing a file through a swing button

I am making a Swing application for light local database management and I have the button Run XAMPP. When that button is pressed this code is executed: ...
2
votes
2answers
104 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
1answer
122 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 ...
3
votes
1answer
153 views

Seeding a file with fake records - doing concurrent updates

I need to seed a database with user data. When trying to write records to a file using sqlite3 with node, I tried writing the logic in a naive manner, without any error checks - but it was failing ...
3
votes
2answers
228 views

Simple structure that would contain validation errors messages

Before I go too far, does this look right? This is mostly to have a "central" place that hold a "hierarchical/structured" errors message. ...
4
votes
2answers
684 views

HttpURLConnection response code handling

This snippet from a downloader callable handles HTTP status codes. I need critique on both the style (for or do-while loop ...
4
votes
1answer
95 views

Is recursion like this safe with a task queue on GAE?

I've written a function to call with the deferred library to generate a large task queue, and at first without the recursion it timed out (deadlineexceeded) so now I'm trying with a recursion but is ...
2
votes
2answers
46 views

Is this an appropriate approach and layout for conditionally continuing execution in bash?

I've seen others use && for conditionally continuing execution in bash, and found it effective but rather ugly. (I'm not sure if there's a better name for this technique.) ...
4
votes
1answer
64 views

How to properly detect multiple devices failure?

My software has multiple devices connected before starting. I must be sure these devices are working and are well connected. every device has different error ID code so we can see every component that ...
4
votes
1answer
89 views

Can I rewrite this with pattern matching?

I've got the following Elixir code: ...
1
vote
1answer
50 views

Use of multiple value errors in Python

Review this code. ...
2
votes
2answers
1k views

Consistent way to handle transient timeouts with WCF calls (timeouts, unreliable network, server load, etc)

I'm currently using the following code to manage calls to WCF services that are unreliable, and or suffer performance load issues due to contention. Right now this code is limited to solving issue ...
4
votes
2answers
100 views

Making a minishell in C. How to improve error control with feoh and ferror?

I've written this minishell but I'm not sure I'm making a correct control of the errors. Could you give me some advice? ...
6
votes
1answer
102 views

Functions that converts day of year to month and day and reverse with error checking

There is no error checking in day_of_year or month_day. remedy this defect. Here is the solution: ...
6
votes
2answers
351 views

Optimising and error handling Linq query

I have 2 tables as below: Downtime DowntimeCode I am then doing this to get the Description field from the DowntimeCode table for the DowntimeCode with the sum highest value in the Downtime ...
6
votes
1answer
116 views

Structuring functions receiving and returning promises?

I keep running into the same pattern with code using promises in javascript. When writing a function which takes a promise and returns a promise, obviously I want to reject the promise I'm returning ...
8
votes
5answers
3k views

Reading from a serial port

I'm receiving data from a serial port in C, using Serial Programming Guide for POSIX Operating Systems as a guide. The data I receive should be always 10 bytes in length but I want to be sure that, ...
12
votes
1answer
509 views

Brainfuck-to-C compiler written in C++

This compiler, implemented in C++, takes brainfuck code and produces a valid (but still obfuscated) C program, which in turn can be compiled to a native binary. Expected usage is as follows: Build ...
8
votes
2answers
141 views

Idiomatic Scala try option code block

Basically, this function returns a list of flights for an airline. But if the airline doesn't exist, I want to throw some custom runtime exception. If that airline does exist, I want to return a list ...
12
votes
7answers
10k views

Euclid's Algorithm (Greatest Common Divisor)

According to Donald Knuth in "The Art Of Computer Programming", the following is how to find the greatest common divisor of two positive numbers, m and n, using Euclid's Algorithm. Divide m by ...
7
votes
3answers
138 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 ...