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 (1)

6
votes
7answers
1k views

Validation that also returns error messages

My Create, Update & Delete methods should return a success and errors list depending up on the result. I want to avoid the ...
4
votes
1answer
32 views

Takes function and throws exception if passed function doesn't throw an exception

The code below is part of a toy test assertion library I've written. I'm looking for feedback specifically on lines 4 - 9. I'd like to extract them from the ...
0
votes
0answers
15 views

ResponseEntity<Error> bad design

We have implemented this pojo to use in the org.springframework.http.ResponseEntity. ...
1
vote
0answers
28 views

Site Registration Code causing multiple accounts to be registered [closed]

I have an app that uses the MEAN stack, recently I have seen a little strange behaviour. Now this doesn't happen every time a user registers, so far it has happened 3 times. When a user registers the ...
3
votes
1answer
52 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 ...
1
vote
0answers
22 views

Parsing latitude and longitude, using Try[T] to ignore errors

I wrote this question asking about how to implement my error handling while still maintaining functional code and based on 200_success's very interesting note on the spaces, I decided to ...
2
votes
2answers
27 views

Memoizing decorator with retries - now with backoff added! (Part 3)

A continuation of Memoizing decorator with retries, part 2, and related to http://codereview.stackexchange.com/a/133493/47529. I liked my decorator before, but especially in my original use case of a ...
2
votes
1answer
24 views

Stored procedure to swap account holders

I'm doing an exercise, and would like to know if what I'm doing is correct and follows the correct structure for rollback in case a transaction fails. I would like to know as well if my ...
2
votes
1answer
30 views

Elixir / Phoenix login controller, allowing multiple attempts

I have a login method in my controller. I would like to get rid of the imperative "thinking" and write something more functional. ...
8
votes
5answers
275 views

Custom list to avoid out of memory exceptions

The following class is a helper to avoid OutOfMemoryException exceptions being thrown when the list is to large so that it is added onto the large objects heap. To ...
3
votes
1answer
72 views
6
votes
3answers
67 views

Four versions of a database-creation function with different error handling

I'm starting a new, small C project and would like to have the safest, cleanest and shortest error handling code possible. Here is a comparison of different ways to handle errors in the same C ...
5
votes
3answers
81 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 ...
4
votes
2answers
38 views

Error-checking macro to jump to specified label given a failing statement

I'm starting a new C projet and I want to have the cleanest and shortest error checking code possible. To that aim, I often use two things : functions return 0,...
2
votes
1answer
63 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 ...
10
votes
3answers
102 views

Userform for getting data from data sheet into a table

I am making a userform that grabs data from a data sheet and puts it into a table: Grabs the data based on what the user wants (Brand -> Items for brand) Allows multiple items to be added Displays ...
1
vote
0answers
17 views

Express middleware to handle errors and send them to Raygun

I signed up for Raygun on Heroku and wrote a middleware in Express to handle the error, however, I am afraid this might block a request from coming through or executing all the way. This article is ...
8
votes
1answer
122 views

Snakes and Letters

This is the "Clean up the words" challenge from CodeEval: Challenge Given a list of words mixed with extra symbols. Write a program that will clean up the words from extra numbers and symbols....
-1
votes
1answer
37 views

More error-checking

The purpose of this code is to check for errors in my code for a custom shell. In a previous answer, they say that my code didn't have error-checking. You need to check the result of every ...
2
votes
4answers
59 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
1answer
61 views

Spring MVC controller

My code has a nasty smell that looks like this: ...
1
vote
0answers
25 views

Throw exception in Spring when loading a file

I have this following piece of code: ...
0
votes
0answers
54 views

Php Ajax script to check server status of sites from db

I am writing a script for a client so hey can check the status of their servers. The script performs ajax requests to get the data as json then poulates the table with the returned json results. is ...
7
votes
1answer
72 views

Class: 2D Variant Array

Note: Yes. It's big. I'm not expecting commensurately long/detailed answers (though if anyone wants to write one, you'll definitely be receiving a substantial bounty). This class is going to be used ...
4
votes
1answer
111 views

TryRetry - Try, Catch, then Retry

I have created a class to try, catch and retry N times. My class also supports retrying asynchronously. I'm wondering if there are better ways to implement this. I'm most concerned with the ...
1
vote
1answer
29 views

Logging errors in google analytics

Apart from general JavaScript knowledge, this snippets requires someone who knows how to properly use Google Analytics API. To log errors on my site, I use this code: ...
1
vote
1answer
81 views

Reading files and displaying their content

I'm writing a program to read two files supplied as arguments in the command line, convert them from list to char[][], and display their contents to the user. I'm trying to practice exception-...
2
votes
1answer
115 views

Getting JSON data from an HTTP response using conditional binding

I am new to Swift and I am trying to use the optional binding feature in as efficient way as possible but I am a bit confused on how to use it (if I can) in this scenario: ...
2
votes
2answers
76 views

Program to edit an address book stored as a JSON file

I was told to come here from Stack Overflow. I'm trying my hand at an address book and the goal is for it to have a bit more of error prevention, for instance for the key "phone" to have 10 digits, ...
2
votes
1answer
80 views

WebAPI Handling fire and forget exceptions

This is a fire and forget task from within an existing WebAPI service. The code below simply sends a log event (might be that a client has connected to the service to perform some task) to another ...
1
vote
1answer
30 views

Validation of uploading images and adding records to the database

I am doing a php project with the codeigniter framework. In my controller, I have a function that does the following. Uploads an image to the server Add a row to the database. The data would be ...
1
vote
1answer
126 views

Implementation of API to create a company account in a database

I'm working on an API that has a lot of controller functions like this: ...
3
votes
1answer
40 views

Varnish - HttpClient Exception Handling

I'm consuming some messages from a rabbit queue. Within the consumer/processor I need to invalidate a varnish cache and requeue the message if the purge failed. I'm using a local purge proxy. The ...
1
vote
1answer
26 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: ...
6
votes
2answers
52 views

End of day receipt emailing process

The following functions/routines are an automation of an end of day receipt emailing process that formerly would take up to an hour, but now takes less than a minute. Things to note: I changed the ...
4
votes
0answers
94 views

Unit Testing Against Exceptions

I am writing a Swift library. I'm writing unit tests for that library. I am afraid that some of the code that I am testing will possibly throw exceptions. In Swift, we can handle errors, but we can ...
0
votes
1answer
80 views

Context manager for SMTP connections

My code right now look like this ...
0
votes
0answers
25 views

Renaming image files based on OCR words

I wanted to rename a large batch of image files, based on a best-guess attempt to OCR words from the file. These are all logos, which generally bear a the name of an organization. The code presumes ...
3
votes
1answer
53 views

Uploading multiple files using a class

Below I have implemented a class that will validate and upload files based on the specified rules. ...
5
votes
1answer
34 views

Transferring data from one file stream to another

I am currently reading Clean Code and for fun and profit, I intended to refactor some of the Java Tutorials and since I wanted to improve my Exception handling, the Byte Stream one with its lots of ...
4
votes
2answers
105 views

Optimize the CSV Upload function in Ruby On Rails

The code is working fine however, I would like to fix code after unless and can I store thread ID in the database too? Is there a way to improve performance? ...
3
votes
2answers
397 views

Count rows of a table

I am trying to count the rows of two tables generated by SQL connections in Excel VBA. My plan was to use ListObject.DataBodyRange.Rows.Count however, this errors ...
3
votes
0answers
42 views

Easy error handling

I've started using the following Error configuration for some simple libraries I've been working on: ...
1
vote
2answers
111 views

Validating username, password, and email in PHP

Let's pretend the following: ...
2
votes
1answer
39 views

Simplified error handling when reading from stdin and parsing to a type

I've recently started learning Rust, and I've managed to whip up this function, which reads and parses a thing from stdin. I don't like it though, and I feel it ...
3
votes
1answer
50 views

Class for Value + Error Code

This is a class similar to std::pair and std::tuple inspired by Alexandresku's ...
2
votes
1answer
42 views

Pushing data to an analytics API

This is code that handles pushing data to an analytics API, and IMO it feels too much like Java. logActivity is a method that uses ...
3
votes
1answer
105 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
1answer
64 views

Disposing of an SQL dataset

I am getting a compiler warning when running my code analysis. It is CA2202. It is saying that I have not properly disposed my dataset through all exception paths. Here is the code: ...
3
votes
4answers
117 views

Copying file dependencies

I have written the following code, and it works great, but I'm not satisfied. I really love the book "Clean Code" by Uncle Bob and I try to apply all his principles when coding, but I'm having a tough ...