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.
5
votes
2answers
112 views
IO and Scanner exception handling
I have created a sample file reading program as an exercise while learning how to implement good exception handling. I want to ask: is this a good approach or is there some other solution that I am ...
1
vote
1answer
34 views
2
votes
0answers
23 views
Restful API for parsing records
I'm trying to implement my own API. This code excerpt should show the basic working routines. The storage is temporary an in-memory-array and the only HTTP method for now is POST.
I outsourced the ...
2
votes
2answers
38 views
12
votes
1answer
120 views
Wanted a cat. Got lolcat
Wanna learn Rust? Ya rly!
I can haz FizzBuzz? No wai!
Gimme /bin/cat then. But rustc say LOL! Must handle teh err0rz!
Now iz ...
4
votes
1answer
53 views
Continuable if error is null
I made a method that I can use to avoid having to handle errors from callbacks.
What it does is, call the passed method only if the first argument is null.
So essentially it will bypass to the last ...
0
votes
1answer
33 views
Asking for a number in Java Swing
Is it good way of asking for a number? Should that function return 0 if there is an error?
...
2
votes
1answer
36 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
40 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
232 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
46 views
Throwing exceptions in a database wrapper
I hope the extension methods ThrowArgumentNullExceptionIfNullOrEmpty and ThrowNullReferenceExceptionIfNullOrEmpty are ...
6
votes
1answer
170 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
35 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
79 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
234 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
71 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
14 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
100 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
276 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
30 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
39 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
101 views
Searching for an account by accountId
I have a piece of code that is fetching account objects from a service
...
2
votes
2answers
85 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
30 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
75 views
1
vote
1answer
45 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
112 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
63 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
129 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
385 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
31 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
378 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
460 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
45 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
63 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
194 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
153 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
130 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
57 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
67 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
148 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
65 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
65 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
94 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)
...