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)

2
votes
1answer
17 views

Playframework (Scala) custom exception handling

I am using play framework with scala and here is a scenario on which I would like to have your opinion. Let's say I have 2 ...
3
votes
1answer
35 views

Functionality for automatic retry after exception

I have made the following system to automatically retry network calls if some exception is thrown. (Earlier posted on stackOverFlow, solution inspired by what @Boris answered) ...
1
vote
2answers
221 views

Replacing thrown exception with more descriptive exception during file I/O

My code needs to open a specific file. Under certain (expected, but rare) conditions, the code will get handed a file path to a file that does not exist -- the path is expected to be otherwise valid ...
2
votes
1answer
44 views

Throwing exceptions in a database wrapper

I hope the extension methods ThrowArgumentNullExceptionIfNullOrEmpty and ThrowNullReferenceExceptionIfNullOrEmpty are ...
6
votes
1answer
162 views

LiveDate version 2

LiveDate has the ability to display the current date either by asynchronously fetching the time from a server or by just using the client system date. It's only as ...
0
votes
0answers
34 views

Designing exception classes [migrated]

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 ...
4
votes
1answer
78 views

String find and replace method optimization

I am trying to find a specific header string from different Maps (LEDES1998Bheaders, LEDES98BIheaders and ...
5
votes
1answer
225 views

Calling other machines from the LinkedList if one is blocked or down

This is a follow on to : Simplifying asynchronous "executeAsync" method along with "onFailure" callback. I am using AsyncRestTemplate as my ...
2
votes
2answers
61 views

Users and friends query with retry, returning JSON

I am new to Azure and SQL. I have the following function that is part of a larger Web-API which is hosted on Azure and is querying an SQL Server database that is also hosted on the Azure platform: ...
1
vote
0answers
12 views

Sourcemap translator service

This is my first attempt to a serious Node.js application, I've tried to follow the async style of Node at my best, but I have several doubts and I am sure that this code can be massively improved. ...
1
vote
1answer
99 views

Validate IP address and create a registration attempt

I'm a C++/Python developer attempting to learn JavaScript, but I'm struggling to write clean code. I've read that async.waterfall and Promises are two ways to flatten the code a bit, but my ...
6
votes
3answers
265 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 ...
2
votes
1answer
41 views

Two error-reporting conventions for a command-parser

I need to implement some function and I would like to report about a fail made inside a function. If function doesn't fail I need to get a some result (for example, ...
2
votes
1answer
29 views

Logging of various exceptions in the callback

I am working on a library in which I need to execute my URL using AsyncRestTemplate and after that I will get a json response back if it is successful. I am also making ...
0
votes
0answers
30 views

Sorting products by name or price

Lets preface this by saying that when it comes to javascript, I am a hack. I make what I need happen by cobbling together crappy, inefficient, redundant code. I want to get better. Recently I was ...
3
votes
1answer
43 views

Deciding whether an anchor should be updated

A colleague and I were discussing the following code today and had a disagreement over the return false in the ...
-1
votes
2answers
100 views

Searching for an account by accountId

I have a piece of code that is fetching account objects from a service ...
2
votes
2answers
75 views

Interfacing with instruments using pyvisa

I'm new to Python, and after running through some introductory exercises I wrote a class definition for working with some hardware, specifically a Signal Recovery model 7230 lockin amplifier. In the ...
1
vote
1answer
29 views

Logging errors with the same exception type

I wrote some code which simply retrieves the HTTP status code of the passed in URL. There are multiple potential causes of the same error. I am hoping to get some all around feedback on this code, ...
5
votes
2answers
73 views

Getting rid of goto without duplication in Go

Consider the following function: ...
1
vote
1answer
41 views

Handling all error conditions on success or failure response

I'm working on a screen where I sent a request and I get response in two types. One is success and contains the below format: ...
4
votes
2answers
111 views

Verifying value before parsing

I am writing some Java code and am coming across a try/catch block in which I decided to verify the value is not null before parsing it: ...
-1
votes
1answer
60 views

Retrying to read a file [closed]

I have a piece code which retries 3 more times to open a file (see below). Are there potential problems or side effects with the way it is written? How can it be improved? Also, why would one use ...
3
votes
1answer
127 views

Servlet responses to upload/download requests

My task is to write a program to store files in object store. One of the subtasks requires to send json or xml format response to the file uploader/downloader as requested by client. The following ...
1
vote
0answers
38 views

Sign-up controller and service

I'm programing server side node for a huge project. And I'm thinking my brains out about the best programming pattern that will be suitable for fast modification and changes. Tell me what you think ...
2
votes
2answers
383 views

Failing fast by raising an exception with a custom message

This is a script that utilizes lazy exception throwing. What I do is decorate a function that might throw an exception to throw an exception with a formatted string. ...
1
vote
0answers
30 views

Custom 503 page for MySQLi connection error

I redirect all my requests to index.php via htaccess and the code below is in my index.php. I want to ask if my code is properly set for a custom 503 page for an unsuccessful MySQLi connection trial. ...
8
votes
3answers
374 views

Exception handling and general check in Java

Are the catch statements ok or must I put in a println()? In general, is the code good-looking enough? ...
0
votes
0answers
26 views

HTTP Responce randomization

I've made some unethical code giving HTML responses at random and masking what is there for fun. It targets mainly crawlers and scripts that run through your website that are looking for ...
6
votes
2answers
451 views

Making error messages more efficient

I am using a way of making error messages, and it works fine. It is just starting to get a little annoying as my project gets larger. I was wondering if there was a way to do with with out having to ...
0
votes
0answers
43 views

Error handling in directory iterator using promises

I wrote this example of IS.File.directoryIterator for Firefox. Can you please help me to review it so if an error occurs it is caught? I'm not so great with ...
7
votes
1answer
34 views

Managing initialization for a vector abstract data type in C

As an assignment, I was to create an \$n\$-dimensional vector type for \$n \le 20\$. This vector only has to support addition and scalar multiplication. I tried to write good code, with proper memory ...
1
vote
0answers
59 views

Use of get queryset and using pass to ignore an exception and proceed in my django view

I wrote a view to update my draft object. Before updating my draft I need to see if any draft exists for package(draft.package) in db or not. If any draft is ...
3
votes
1answer
173 views

Ruby selenium script waiting for an element to disappear

I'm a Java developer, I'm new to Ruby and I'm worried that I'm forcing or not-so-well using the goodness of the Ruby syntax. What do you think about the Exception catching and how to print it in ...
-2
votes
2answers
141 views

return inside a loop - is it a good style? [closed]

Is it a bad style to return inside a loop? I have the following method ...
2
votes
1answer
52 views

Error checking in function that returns reference to static variable

This is a function I just wrote with the goal to only load the desired information once, and if an error occurs, save it for later so that it can always be reported to a calling function. It does ...
0
votes
2answers
112 views

Extract data from database and write them to file

I wanted to write a program that performed a query to a database, then formatted the data before writing it to a file. I thus created 4 classes, which are: a main class a class dealing with the ...
1
vote
1answer
56 views

Making an HTTPS request more readable

I think the snippet is too nested having too many blocks. It needs to be refactored to make the logic more readable. The try exception is the first level block ...
1
vote
1answer
63 views

Handling errors when using PDO to connect to a database instead of MySQLi

What would be the preferred method for handling errors when using the PDO to connect to a MySQL database? I was using mysqli_error($this->pdo), but I heard this ...
3
votes
0answers
142 views

Exception logger for servlets and JSPs

I hate using unnecessary catch blocks and I like to see my code look beautiful. In most of the cases in my project, which is a web application, I can't declare many ...
0
votes
0answers
63 views

Is this a safe way to do my own embedded dialog and exception handler?

I'm developing a multi-platform app via Delphi XE7 with the Firemonkey framework. I wanted to eliminate the sloppy Windows exception modal window, so I created my own in-line modal prompt dialog. It's ...
4
votes
1answer
60 views

Do you view this ThrowingFunction interface as “interface abuse”?

I am currently implementing a fun project involving lambdas and this project makes heavy use of the ability of Java 8 to have default methods in interfaces. But when does such "heavy use" turn into ...
7
votes
3answers
90 views

Checking for intersection points

The aim of the program is to find those points which comes under the intersection of at least 2 circles.(space is a 1000x1000 matrix) ...
7
votes
1answer
66 views

Controller action to process orders and payments

I'm trying to reduce the if statements and simplify this create action. ...
3
votes
2answers
987 views

Multi threaded TCP server

I wrote this just for fun, to hone my exception handling skills. I want to know what I can do better in terms of exception handling (and otherwise) in the below code Server ...
5
votes
3answers
444 views

Try/catch in a Tic-Tac-Toe game

I'm looking at my code and it doesn't look very efficient. I'm simply trying to catch exceptions or prevent them from being thrown in the first place. Can you please take a look and tell me if there ...
4
votes
2answers
84 views

Querying MongoDB for information on a collection of books

I have this huge chunk of code. Is there any better to write this code, or am I too paranoid that I check every MongoDB query for error? The logic is here: Bookcollection = collection of books Book ...
0
votes
1answer
65 views
1
vote
2answers
112 views

Stop connecting to a server after n unsuccessful attempts

I am trying to connect to a server. If the connection goes through, then print an apt message. If the connection does not go through, try for a total of n times. And quit after the nth attempt ...
5
votes
4answers
391 views

Java Stream Exception Handling

I find this piece of Java code really ugly and cumbersome. How can I refactor it to be more clean and easier to read? ...