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
57 views
+50

Throw an exception which contains a nested set of previous exceptions - excessive use of exceptions?

I have a set of domain objects which try to find a solution to a problem. The top level object has an algorithm which splits up the problem and delegates it to lower level objects, which in turn do ...
1
vote
1answer
40 views

Array search algorithms: performance comparison

I'm making a program that compares multi-key sequential search and Interpolation search in a sorted array by the number of array accesses for my assignment. ...
1
vote
0answers
22 views

Uploading LDAP search results to an FTP server

I know this is quite a generic question, I was hoping it could stay open so I can try to improve my styles. Basically, I have an application that connects to LDAP, performs searches, and produces a ...
0
votes
2answers
38 views

Concatenating multiple strings from a JSON response

I would like to concatenate a series of strings populated from an XHR response. So, I've chosen to do it like this: ...
3
votes
1answer
68 views

Retry Runnable java

I want to make class to retry doing what I want if specific exception happen for n times before throwing exception, so I write below class and used Builder to build it could you please review it and ...
-1
votes
0answers
37 views

Get or generate a GUID for content stored in a CMS

The code below is trying to get a GUID in a Content stored in a CMS. If it's not stored, then a new one is generated, stored and returned. I'm sure many of us are having troubles when it comes to ...
3
votes
2answers
55 views

Delay to avoid cocurrent modification

I was attempting to remove items from an ArrayList while iterating through it, only to find out that Java doesn't like that. So I quickly wrote up a ...
4
votes
2answers
36 views

Raising an error if a variable is not created during class initalization

I would like to properly raise an error if self._header was not created when I initialize a NewFile object. This is working ...
2
votes
2answers
49 views

Controller method to validate and save

I have built RESTful web services. The services endpoints have a similar logic: If the input validation succeeds, do a database operation and return the result. If the db operation fails, return the ...
23
votes
6answers
3k views

Unbreakable average program

I'm creating a program that averages four numbers - three from a file and one from user input. Simple enough. But the catch is, the professor is going to be deliberately trying to break the program. ...
4
votes
1answer
187 views

Layered architecture implementation in a Java web application

I am trying to learn how to design and implement a layered Java web application with a presentation layer, service layer and the DAO layer. I have used the Struts 1.3 framework with Java JDK 1.6 for ...
3
votes
1answer
62 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
273 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
60 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 ...
8
votes
0answers
44 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 ...
6
votes
2answers
471 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
73 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
54 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

Property file loader

I have the following code: ...
4
votes
2answers
72 views

Printing gitignores

I have written a simple program in Java 7 to write the .gitignore of different file types: ...
2
votes
2answers
51 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
285 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
144 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
54 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
90 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
27 views

Test web application

I am writing a test web application in Golang. Create post handler: ...
1
vote
0answers
36 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
31 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
238 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
49 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
67 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
317 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
57 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
549 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
64 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
99 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
330 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
92 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
127 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
2k 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
80 views

Logging mechanism

I have the following code: ...
2
votes
1answer
55 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
113 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
41 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
119 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
97 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
52 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
53 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 ...