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.
1
vote
1answer
32 views
Use of multiple value errors in Python
Review this code.
mode = "PARALLE"
try:
if mode == "PARALLEL":
# some code - this will not raise ValueError
elif mode == "SERIES":
# some code
else:
raise ...
0
votes
2answers
52 views
Consistent way to handle transient timeouts with WCF calls (timeouts, unreliable network, server load, etc)
I'm currently using the following code to manage calls to WCF services that are unreliable, and or suffer performance load issues due to contention.
Right now this code is limited to solving issue ...
4
votes
2answers
58 views
Making a minishell in C. How to improve error control with feoh and ferror?
I've written this minishell but I'm not sure I'm making a correct control of the errors. Could you give me some advice?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
6
votes
1answer
46 views
Functions that converts day of year to month and day and reverse with error checking
There is no error checking in day_of_year or month_day. remedy this defect.
Here is the solution:
int day_of_year(unsigned int year, unsigned int month, int day) {
int leap, i;
leap = ...
5
votes
2answers
163 views
Optimising and error handling Linq query
I have 2 tables as below:
Downtime
DowntimeCode
I am then doing this to get the Description field from the DowntimeCode table for the DowntimeCode with the sum highest value in the Downtime ...
6
votes
1answer
71 views
Structuring functions receiving and returning promises?
I keep running into the same pattern with code using promises in javascript.
When writing a function which takes a promise and returns a promise, obviously I want to reject the promise I'm returning ...
7
votes
4answers
195 views
Reading from a serial port
I'm receiving data from a serial port in C, using Serial Programming Guide for POSIX Operating Systems as a guide.
The data I receive should be always 10 bytes in length but I want to be sure that, ...
9
votes
1answer
230 views
Brainfuck-to-C compiler written in C++
This compiler, implemented in C++, takes brainfuck code and produces a valid (but still obfuscated) C program, which in turn can be compiled to a native binary.
Expected usage is as follows:
Build ...
12
votes
7answers
1k views
Euclid's Algorithm (Greatest Common Divisor)
According to Donald Knuth in "The Art Of Computer Programming", the following is how to find the greatest common divisor of two positive numbers, m and n, using Euclid's Algorithm.
Divide m by ...
6
votes
3answers
112 views
Exceptions handling, what would you do?
I know that there are several ways to handle exceptions and probably a good way is to keep the handling consistently and use the pattern which feels comfortable for himself, but I would like to get ...
1
vote
2answers
88 views
A Tour of Go, problem #56 - error handling
New to Go, trying to solve Tour of Go, Exercise 56, which is about error handling.
Can the following error handling method can be further improved?
package main
import (
"fmt"
"math"
)
...
3
votes
1answer
149 views
Shoot me for my nesting… then could you please help me with a better thought process
I have the following method that's in a common library. It's ugly - fair warning. I want to know how to write it better, but mostly, I want to know how to think about this better so I don't end up ...
5
votes
4answers
301 views
Cleaner way of returning true/false with error message
What's a concise way of returning true/false with an error message?
Here's a concrete example. I'm building a parser that takes in a file. ParseReplayData does some validation before proceeding with ...
2
votes
2answers
121 views
Error handling, general architecture and commenting style review
I'm writing a C++ wrapper library for sockets which will hopefully be cross-platform.
It's basically two headers: mizaru.hpp, which contains the wrapper classes themselves, and trans_layer.hpp, which ...
1
vote
1answer
121 views
Handling nil: Trying to avoid #try
Yesterday, I introduced a bug into our codebase by calling #titleize on a string that could possibly come in as nil:
def route
medication.route_name.titleize
end
This threw an error on production ...
2
votes
2answers
273 views
Saving and listing Category model
I have this ExpressJS route for saving and listing Category model.
exports.save = function(req, res, next){
//validate here>>>
var name = req.body.name;
var description = ...
1
vote
0answers
168 views
Catching all exceptions and errors in PHP
I've tried to catch all exceptions and errors in PHP in a way so that I can deal with them consistently.
This is the code with the exception of the very last bit where I instead pass $e on to a ...
2
votes
1answer
567 views
Setting variable if it doesn't exist in Dictionary [closed]
I was wondering if this was good design from client side calls. In the event that the key doesn't exist, go ahead and add it.
public static void SetVariable(string name, object value)
{
if ...
2
votes
2answers
126 views
error handling logic in php
I'm wondering if you see anything terribly wrong with this code, or if you see any areas for improvement. My objective is to make sure its simple enough for someone else taking over my job to be able ...
1
vote
1answer
309 views
Best way to handle repetitive error code or return value
I have a wrapper which interacts with a third party component. In Each function i am performing the operation if it the component is initialized.
I have other function to check the errorCode and ...
3
votes
2answers
189 views
Storing and iterating over multiple NSError pointers
How would you refactor this kind of code? I've unsuccessfully tried several approaches (NSArray, NSPointerArray, plain C array), but always ran into pointer type checking error.
NSError *error1;
...
4
votes
2answers
439 views
Splitting a string of random length
I am currently using this code, but I am pretty sure there is a better way of doing it:
private string ReturnEmployeeName(string userName)
{
try
{
// Username coming is ...
2
votes
1answer
206 views
Suggestions for improving error handling
I am interested in finding out what is the correct way of implementing error handling for this situation in C#.
The system tries to do an operation. If the operation succeeded (returns a non-error ...
0
votes
1answer
203 views
What is wrong with these PHP arrays, is_array returns false and foreach says invalid [closed]
I have hit a brick wall in my project: PHP doesn't consider the $bon_v1 an array.
What is wrong with all of this/ some of this?
$bon_r1 = array(
"in" => "#pp1",
"ot" => "bon-r1",
"fn" => ...
2
votes
2answers
146 views
Add events dispatching for ActionScript framework Robotlegs
I have the following function in a Service class
protected function writeToFile():void{
var destinationFile:File = File.applicationStorageDirectory.resolvePath(_newPath);
var ...
2
votes
2answers
888 views
HttpClient error handling
I would be happy to hear feedback on my implementation of httpclient. I am not so strong with error handling so I want to improve. My thought process behind this was that IOExceptions can be ...
0
votes
1answer
61 views
uplifitng return value error reporting to Exception based error reporting
In Framework Design guideline book there is a chapter about Exception and they talk about return-value-based error reporting and exception based error reporting and the fact that we in a O.O language ...