Questions tagged [error-handling]

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.

Filter by
Sorted by
Tagged with
23
votes
3answers
12k 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. ...
8
votes
1answer
5k views

Yii exception usage

I've never used a framework before, so I wanted to see if this fairly simple scenario was done correctly or could be improved: ...
16
votes
5answers
122k views

Try catch statement in VBA using the standard VBA error handling statements

The code below is pretty self explanatory: just copy and paste it all into a module and run it, it provides a few use cases and many explanatory comments in the text. (It works but I'm interested to ...
28
votes
3answers
2k views

A Failable<T> that allows safe returning of exceptions

This was inspired by a conversation in chat, that started with the discussion of C#7.0 tuples and out parameter declarations, which led to the idea that there is no 'good1' way to return an error ...
9
votes
4answers
898 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
1answer
68 views

Part 2: Send HTTP request for each row in Excel table

This script was previously reviewed here: Send HTTP request for each row in Excel table (Part 1) I've made the changes that were suggested in the Code Review answers as well as added a few of my own. ...
10
votes
1answer
4k 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 ...
15
votes
2answers
1k 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 ...
10
votes
2answers
2k 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 ...
5
votes
1answer
158 views

HSTS Recommendations in .htaccess

Please see my previous post in the below hyperlink I've updated my .htaccess file to account for an HSTS, along with many of the recommended changes. See the ...
4
votes
1answer
4k views

Concurrent/parallel ForEachAsync - proper handling of exceptions and cancellations

I've created an asynchronous parallel ForEach mechanism so I could enumerate an enumerable by N degrees of concurrency and process an action for each item. ...
11
votes
2answers
1k views

Memoizing decorator that can retry

I have some tasks that I'd like to memoize because they connect to a rather slow network and have to wait for the data. Unfortunately this network can be a little finnicky and we get occasional ...
10
votes
1answer
264 views

Post json using http and verify whether all actions completed successfully or not

I am working on a project where I need to work with http apis and call them using Python language. Below is what I need to do: Take few input parameters like - <...
5
votes
2answers
6k views

Python decorator for retrying w/exponential backoff

This is my first decorator in Python! I found some of it on the internet but have tweaked it to our needs. Here is the couple concerns of mine: Multiple python version compatibility Is grabbing the ...
2
votes
1answer
82 views

Connect to database, handling errors

I try to handle or catch possible errors with PHP/MySQL for security reasons and would like to know if I'm doing it right. The first case, connection: I use it as a function and call it always when ...
17
votes
7answers
92k 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 n ...
18
votes
3answers
11k 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 ...
18
votes
2answers
6k 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 <...
14
votes
1answer
112k views

Reading data from Excel sheet with ExcelDataReader

Objective: I want to import an Excel file, and read the rows of certain columns. For this, I use ExcelDataReader. I've implemented a low-level class called ...
38
votes
6answers
3k views

Resolving a link

How can I clean this up? ...
10
votes
3answers
7k views

Encapsulating common Try-Catch code. Is this a known pattern? Is it good or bad?

In an effort to reduce code duplication, I often use and have used this style to capture handling of exceptions on a boundary of an application: Given the following extension methods: ...
8
votes
1answer
168 views

RPN calculator with interactive and non-interactive modes

While writing this review, I edited the code until it became something quite different from the original. In addition to the issues I mentioned, I ended up adding features: More operators / ...
6
votes
2answers
10k views

Async and error-handling

I need to delete a file when an error occurs during loading it. It is not allowed to perform async operations in a catch block. This has lead me to writing the following code: ...
5
votes
3answers
12k 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 ...
3
votes
1answer
65 views

Create Table After Deleting Rows Before Desired Range and Filter to Delete All Other Unnecessary Rows

The code below first searches for the first searchText and deletes all rows that precede it to establish a range for a table object. Once the table object is ...
14
votes
7answers
4k views

Imposing a sort order on a query

I've always been told "never use goto, there's always a better way" and for the longest time I just accepted it. Lately though, I've been running into such scenarios in which I have to repeat this bit ...
11
votes
5answers
10k views

Validation that also returns error messages

My Create, Update and Delete methods should return a ...
7
votes
2answers
718 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. ...
5
votes
5answers
3k views

Map error messages to conditions

I have a method which checks some preconditions and if everything is fine returns a success response object, otherwise fail with ...
4
votes
1answer
151 views

.htaccess Recommendations

I have a personal website that's used primarily for fun. I upload images, videos and text that I want to share. An HTML submission form accepts questions and string submissions from users, which uses ...
3
votes
2answers
6k 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 ...
1
vote
1answer
409 views

Error-Handling Class and Logging

I am relatively new to C# and would like to see if what I have been using for my exception handling, message and logging is along industry standards. I have created a simple class for the Error ...
11
votes
4answers
612 views

Get Workbook Method(s)

I'm re-writing my Module of standard methods. These 3 are used to retrieve Workbooks as Workbook Objects. The standard I'm aiming for here is "Third-party Library/Add-in". So: Do these functions ...
10
votes
2answers
362 views

Creating a pseudo Pivot Table / Database using a 4-D array

Why am I not just using a Pivot Table / Database? a) I've never ever used either before. And I don't have time to learn how before this project needs to actually be finished. b) The final output ...
8
votes
3answers
3k views

Catching multiple types of exceptions when writing JSON

I have a class which throws a lot of exceptions: ...
7
votes
3answers
2k views

Simplifying asynchronous “executeAsync” method along with “onFailure” callback

I have a system in which user id is "sharded" across all the machines which means each machine is responsible for certain user id data. I am working on a library which will take ...
6
votes
1answer
157 views

Send / receive wrapper for System.Net.Sockets

The following NetworkEndpoint class serves as a simple send / receive interface for either side of a network connection (client or server) when provided with a ...
6
votes
3answers
505 views

Parsing excel cells containing line feed characters

This is a direct follow up to Parsing cells containing Line Feed Characters. Link to sanitized xls on dropbox if test data is needed Essentially the reports I work with aren't bad - The issue is ...
5
votes
3answers
303 views

Memoizing decorator with retries, part 2

A while ago I asked this question Memoizing decorator that can retry and then promptly forgot about it. I more recently saw Python decorator for retrying w/exponential backoff and wanted to add ...
5
votes
1answer
309 views

Reading the contents of an XPI file

I wrote this code to list contents of an XPI file and then read the contents in it. I was thinking of these areas of improvement: I put the zr.open in the ...
5
votes
2answers
260 views

URL decode a string but log an error after second exception

I have a method which does URL decoding on the string value passed along with using Charset: ...
5
votes
1answer
335 views

Rethrowing exception just as an information

I have something like that: My custom exception class: ...
4
votes
1answer
243 views

General Retry Strategy #2

Previous version Now supports async operations and cancellation. Let’s say we copy some file using retry strategy (it might be blocked, etc.). App code comes bellow: ...
4
votes
0answers
745 views

Rust-like “Result” in C - nicer error handling

There are frequently things I miss when using C; one of them is a nice error-handling (exception-like) system. After trying Rust, I realized I could implement something similar in C itself. So here's ...
4
votes
1answer
647 views

Script to create symlinks for dotfiles in a Git repository

I have a GitHub repository containing all my dotfiles for bash, tmux and neovim. I'm using a ...
4
votes
3answers
641 views

General Retry Strategy

Let’s say we copy some file using retry strategy (it might be blocked, etc.): ...
3
votes
2answers
134 views

Generic error handler function for POSIX shell scripts

Intention I came with the idea of generic, portable, highly reliable, and further customizable function for Shell scripts, written in POSIX, for error handling. Purpose The function shall find out, ...
3
votes
1answer
126 views

Linq-to-Sage: CRUD Operations

Following-up on my Linq-to-Sage implementation, I ended up implementing all CRUD operations, following the Sage 300 view protocols. So, the entities derive from classes that look like this: ...
3
votes
0answers
358 views

Stylishly saving source

Simple tool to save a web page's source. A result of trying to learn and apply an MVC approach. The FXML is generated via Scene Builder, but included for completion. I welcome any general feedback on ...
2
votes
2answers
982 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) ...