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.
3
votes
1answer
42 views
Custom error/fatal error and exception handler in PHP
Introduction
I wrote three functions that aims to log errors and exceptions as well as show a user a generic error page. Would appreciate some feedback on it with regards to the PSR standards and if ...
4
votes
2answers
265 views
forever.sh - should keep a process alive forever
This script's only responsibility is to keep a process alive. Forever.
It's sole dependencies shall be bash and coreutils. I'm ...
3
votes
0answers
31 views
“Extending” the Swift 2 ErrorType protocol
I am building a simple REST client in Swift 2. The methods the client offers can return errors. Every method returns the same errors (network problem, unauthorized, etc...). But each method can also ...
6
votes
0answers
26 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 ...
7
votes
2answers
449 views
Servlet file uploader
I think this code looks ugly, especially with the multiple try-catch blocks, but I don't know how to rewrite it:
...
6
votes
1answer
72 views
Avoiding code repetition while handling exceptions
For my application, I need to use two slightly different algorithms for persisting an entity:
...
3
votes
2answers
41 views
Netscape bookmark file generator
I started to learn Rust some time ago and I wonder if there is some way to write Rust code that is both concise and safe — in particular, avoiding unwrap(), casting ...
4
votes
2answers
50 views
4
votes
2answers
69 views
Printing gitignores
I have written a simple program in Java 7 to write the .gitignore of different file types:
...
2
votes
2answers
49 views
Root-finding by iterated bisection
Both of the following code give the same result. But I'm not sure where should I put the raise statement.
...
2
votes
2answers
113 views
Load text file into an array in Swift
I'm drowning in Swift optionals and error handling syntax. I'm just converting a text file into an array of Strings. One would think that this could be a simple two or three liner but by the time I ...
10
votes
1answer
134 views
C++ alternative to exceptions
I've been thinking about error handling in C++ lately. Exceptions are a great way of handling errors in most applications. However, I work in the games industry where it is commonly accepted that ...
0
votes
1answer
42 views
JUnit test case to check that an exception of type javax.mail.MessagingException is not thrown
I have a method which will send a text mail using JavaMail API and I am trying to write a test case for this method which will check if an Exception of type ...
2
votes
4answers
88 views
Getting LinkedIn details
Each field is prone to throw an exception if not found. If one element not found, then the next should be checked. I have put each element in a separate try/catch. Is this a correct approach or can it ...
2
votes
0answers
20 views
1
vote
0answers
30 views
Dynamically created Exception classes
This is a question about best practices. I have a project I am building and I have the following base Exception class:
...
0
votes
1answer
29 views
Class and Static practice, IDS and a max instance count [closed]
I was practicing working with classes and the static property included with them and came up with a simple ID counter and max number list. I also added a quick debug error ...
10
votes
2answers
227 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 ...
3
votes
1answer
40 views
Catch all checked exceptions and turn into unchecked exception
I am currently trying to learn Lambdas and following the book Java SE8 for the really Impatient and just finished Chapter 1 of it. This is the question, I am trying to get done with:
Didn’t you ...
4
votes
2answers
61 views
Handling request errors in snap with haskell
I'm currently taking a look at Snap with Haskell. I'm pretty new to Haskell and functional programming in general and am working out the best way to handle errors. Currently I have something like this
...
11
votes
2answers
266 views
Returning result and error status for number type conversions
Looking for review of design strategy of using a struct to return the functional result and error status. Your experience of how my design approach may succeeded ...
-3
votes
2answers
54 views
Raise, handle and note down the custom exceptions [closed]
I am creating a custom Exception class and trying to log the CallerFilePath, ...
13
votes
6answers
527 views
Storytelling program: Gathers stories from certain popular story websites/formats and reads them aloud
Audiobooks make my life easier when I have idle ears and a mind free to wander, but something better for my eyes to do.
This program is one of my more recent efforts to allow most of the stories ...
4
votes
1answer
48 views
Handling an invalid SQL query exception
This is my DAO object that takes the Cypher query as a string, and returns a JSON representation of the graph it returns.
Because it's using a Spring JdbcTemplate ...
13
votes
7answers
1k 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 ...
1
vote
4answers
75 views
Python Decorator - inspecting function argument values
Some of my functions use a "fail_silently" flag. It is used in the following way:
...
2
votes
1answer
195 views
Checking for Internet connectivity on Android
I wrote this code to check an internet connection and was wondering if this is the best way to do this check.
...
4
votes
2answers
85 views
Get an integer as input and display Pi rounded to that amount of decimal places
I've been writing a program that accepts an integer as input and displays the number Pi rounded to that number. The only issue I see is the fact that the Math.Round ...
2
votes
1answer
83 views
Program simulating dictionary using file handling - part 2
This is the new version of the dictionary program which I uploaded for reviewing here.
I would be grateful if the program could be reviewed for all the points mentioned in the above link.
...
6
votes
3answers
741 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 ...
1
vote
2answers
74 views
2
votes
1answer
50 views
Backing up two tables using SQL transactions
I'm using a transaction statement in SQL Server 2012 for the first time.
I want to insert Table1's data in Table1_Backup before ...
7
votes
1answer
100 views
Proper checked exception handling with lambda functions
I'm having trouble finding a clean way to handle checked exceptions thrown by a lambda function passed as a parameter in Java.
I'm writing a Client which will interact via RMI with a Server to play a ...
0
votes
1answer
36 views
Retry storing HTTP response into a variable until specific code
I want to keep trying to get response until its code is 200 or unknown yet. In first case it should be stored in response variable. In another case I should raise ...
10
votes
1answer
107 views
Try-except decorator for classmethods
This question is related to the Cactus Text Game Engine.
For easy error handling in Cactus, we've put together this small decorator. Essentially, the decorator wraps any class method in a ...
4
votes
1answer
36 views
Monitoring and re-establishing a PostgreSQL connection
Within a complicated Ruby project, I need to monitor the connection to a PostgreSQL database, as answered here. I use a thread for this purpose. Every few milliseconds, I invoke "consume_input" which ...
-1
votes
2answers
84 views
Creating music using the JMusic API
I'm trying to write a program that creates music, and I am using the JMusic API to accomplish this.
These are the following constants defined in JMusic that I'm using:
...
2
votes
1answer
38 views
Generating URL and status for an S3 bucket
The following program generates the S3 URL and response (status code?) for the key, provided the bucket name and if the S3 URL is a mess (wrong url), then it generates empty string as URL and error as ...
1
vote
1answer
52 views
Exception handling for a chain of prompts
I am trying to make an inputin() function to take all the parameters input for the first time with exception and for individual parameter for the runtime ...
8
votes
4answers
375 views
C# PasswordService class
I am new to C# and develop a configurable PasswordService class. As the code works the next step is to improve the code.
Right now there are the following options:
...
5
votes
5answers
187 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 ...
8
votes
1answer
85 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 / ...
1
vote
1answer
89 views
Custom error handler for PHP
I've written a custom Error handler for use in PHP. What it does is simply capture PHP errors, and logs them using Monolog.
It works, but I can't help that it has too much stuff inside. I could ...
10
votes
2answers
448 views
Inline error checking in VBA
I asked a question elsewhere on Stack Exchange and was given an answer by multiple people that checking for errors in-line was not a good practice. I have been using an
...
3
votes
1answer
89 views
Error handling for Stripe credit card processing
I have a rails application that uses Stripe for credit card processing. Currently several exceptions are being handled anywhere a transaction takes place. The code below is being used currently in 11 ...
15
votes
5answers
755 views
Populating a ListView with Items
I populate a ListView with Items. Each Item has data attached to its .Tag property.
Over time, I have needed to handle many cases where something would be null or ...
5
votes
2answers
159 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
47 views
2
votes
0answers
47 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
109 views