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.
2
votes
2answers
53 views
Recording a customer's shopping cart as an order
I have come up with the following method to post a transaction to a database, in the context of an e-commerce Java web application. The transaction consists in submitting a new order alongside its ...
5
votes
0answers
42 views
Error Handling for XML parser
I have the following Ruby code, which parses an XML document sax style (it's a very simplified version):
...
4
votes
1answer
46 views
Function outcome: consistent approach and easy logging
My goal is to make a consistent and easy way to determine how a function fails/succeeds. I'm looking for code review of my Status class for any bad practices, code ...
8
votes
2answers
47 views
Querying Facebook for details of a user's OAuth token
This class exposes the public method getAuthToken which takes a user's Facebook OAuth token as an input parameter and queries Facebook for information about it - ...
0
votes
0answers
41 views
Exception-logging handler for the DAO layer
I'm a bit clueless on how to handle exceptions. What I've think so far is to use a custom error page for the users so they can't see the full exception for security reasons and log the exception in a ...
11
votes
4answers
150 views
Get Workbook Method(s)
I'm re-writing my Module of standard methods. These 3 are used to retrieve Workbooks as Workbook Objects. The standard I'm aiming for here is "Third-party Library/Add-in". So:
Do these functions ...
5
votes
1answer
31 views
Fetching lists and finding one with the right name, with fallback on error or no match
I have a simple function:
...
5
votes
2answers
36 views
Single class which holds response and error message
I am working on a library which will make HTTP call to my rest service basis on inputs passed to this library. And whatever response comes back from service whether it is successful response or ...
3
votes
2answers
46 views
ErrorManager management
Recently I created a class that would manager errors, log them, and write details about them to files when the function logError was called. It would be done by ...
1
vote
3answers
96 views
Retrying a web request in Python
Is it fine to retry a web service call like this in Python? Would there be any scenarios the exception might not work the way we expect it? I expect it to continue only if it's fine, otherwise just ...
3
votes
0answers
26 views
Stylishly saving source
Simple tool to save a web page's source. Styled to resemble Sublime Text, given frequent personal use. I took the opportunity to learn and apply an MVC approach, the FXML is generated via Scene ...
5
votes
2answers
127 views
Design watchdog, reconnecting to server
I have console application that sends and process XML data. I have created a fault mechanism that the connection drops. I go in a "fault" mode. And try to reconnect to my server. I'm sending ...
3
votes
2answers
421 views
Read sales transactions from Excel
This is a program to read and store the data from a Excel file (.xlsx) which is uploaded by users.
Any better approach to reduce the usage of if-else to return the error message?
How to design or ...
0
votes
1answer
66 views
Two similar functions for writing data to binary file using BinaryWriter
I have two functions for writing data to binary file using BinaryWriter.
The first function has single data object as argument and looks as below:
...
5
votes
1answer
35 views
Initializing an EGL display
I'm somewhat new to writing real-world projects in C, so I'm not familiar with best practices and standards. I'm writing code dealing with EGL and OpenGL, and some setup calls might fail for reasons ...
3
votes
2answers
46 views
AppVersion Struct & VersionParse Exception
I am working on an app that will interact with assembly (app) versions. I created a struct for that, along with an exception for parsing error.
Here's the code:
...
0
votes
0answers
19 views
1
vote
1answer
32 views
Handling success and failure when retrieving product information
I've got an Angular controller where I have two functions that are repeated inside two functions:
...
2
votes
2answers
57 views
Implementing bounds-checking with exceptions based on an existing bitset container
BitPat here is a wrapper around a bitset.
...
3
votes
2answers
98 views
Throw an exception which contains a nested set of previous 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
49 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
23 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
44 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
87 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 ...
3
votes
2answers
60 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
37 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
51 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
244 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
99 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
276 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
111 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 ...
10
votes
2answers
84 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
507 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
81 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
70 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
61 views
4
votes
2answers
74 views
Printing gitignores
I have written a simple program in Java 7 to write the .gitignore of different file types:
...
2
votes
2answers
71 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
846 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
152 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
91 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
96 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
29 views
1
vote
0answers
48 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
36 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
258 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
102 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
84 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
...
12
votes
2answers
424 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 ...