Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [error-handling]

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.

4
votes
0answers
25 views

Python: Exception handling in a logic gate

I'm learning about Python and am going through the OO-stage where I'm building a set of logic-gate classes. To make the logic more resilient, I only want the user to be able to enter a value of 0 or ...
-3
votes
0answers
13 views

Interpreter raises an error that has already been corrected [on hold]

I'd really appreciate your help, I am a complete newbie to Python and to programming in general. This error is raised when I am trying to execute the code below from command prompt: ...
3
votes
0answers
38 views

Copying content from Excel into PowerPoint as a picture, with error handling

The code below works, but I want to ask if my solution is adequate or if there's something I should structure differently. If it's alright, I'll apply the same code in other subs. My code copies ...
5
votes
1answer
31 views

Enum for handling network request errors in Swift

I'm working on a new API written in Swift 5 and I wanted to play with the new Result. I wanted to know what you guys think about this syntax: ...
-2
votes
0answers
13 views

Pseudocode supposedly has an error in it [closed]

Recently finished an exam where I had to spot multiple errors, I can't seem to find 1 from the pseudocode: ...
-2
votes
0answers
21 views

NZEC Error in DFS traversal of a tree [closed]

I have all the nodes of a tree in an ArrayList<Node> nodes and my edges are in given in the arrays u[] and ...
3
votes
0answers
19 views

Connect to a database with Diesel

New to Rust and would like some clarification on idiomatic and readable use of Result and Error types. Here I'm simply connecting to a database using Diesel. In my opinion, the use of match and Boxing ...
4
votes
1answer
525 views

Should my Json storage handle exceptions?

I made a class to conviniently serialize/deserialize data. Now I'm stuck with the following question. Should I handle exceptions (use try-catch) inside JsonStorage ...
0
votes
2answers
74 views

Custom Error Classes in OOP

I have a class which parses a .csv file and converts it into successful rows and errors. Currently I have 12 different kind of errors (mail is not valid, missing column x, row is duplicate etc.). ...
1
vote
1answer
37 views

Decode Argon2 parameters and handling decode errors

I am writing a function to decode Argon2 hashed string to extract parameters. I need to handle many decode errors, and handle those errors lead to write many repeating ...
1
vote
0answers
28 views

Temporarily block API calls when server sends a 503 response

I have a scenario in which I call many APIs throughout my application lifecycle. In case the server sends me a 503 response code, it will also send a lockdown object which has a timestamp associated ...
2
votes
0answers
29 views

DirectX11 Error Handling

I'm new to C++, been a C programmer most of my life. I wanted to get into graphics and Direct3D is C++ so I figured it was about time. I've been learning about strings, vectors, references, smart ...
6
votes
2answers
121 views

Simulation of a banking system with an Account class in C++

I have been learning C++ and recently I have started practicing classes. I made this simulation of a banking system with an Account class. I would like to hear feedback on my code, what is good - what ...
1
vote
0answers
18 views

Requests / Facebook API - Dealing with Errors

I work in marketing and I am currently trying to aggregate data for 50 facebook pages on the same Business Page. I have a loop ...
2
votes
1answer
36 views

Retry a Promise resolution N times, with a delay between the attempts

I want some JavaScript code to take 3 things as parameters: A function returning a Promise. The maximum number of attempts. The delay between each attempt. What I ended up doing is using a ...
1
vote
0answers
37 views

Rethrowing Error through several classes [closed]

This is a simplified version of my app. It has a bunch of scraper classes, and a Job class, which controls the collection of data, and the saving to the db. During scraping it could happen many ...
1
vote
1answer
86 views

VBA Function Error Bubbling

What will be the best practice to create an efficient error handler in object class in VBA? Creating some for Outlook (used later in both, Excel and Access) and trying to get the most efficient and ...
2
votes
1answer
43 views

Constructor for a packagetarget struct

As many of you know goto is usually signs of code smell. However I thought this could be an appropriate case, and would like confirmation or criticism. Unnecessary ...
5
votes
1answer
69 views

Error handling function (Win32/C)

I have written the following function to be a general "error logging" solution for my Windows API projects. Basically, given a Windows system error code (a la ...
1
vote
1answer
29 views

Page download with reattempts in Scala

I wrote the following code to deal with possible network problems. ...
4
votes
1answer
60 views

Node.js http retry do while mechanism

I have implemented a simple do/while loop to handle a http request to a third-party. I don’t know when the data I receive will have elements in its array so I retry up to 10 times until the array ...
11
votes
3answers
2k views

Decoding assembly instructions in a Game Boy disassembler

I am coding a game boy disassembler in C++. The program (simplified here) converts a vector of byte into an assembly instruction and print it. To do so, it iterates through the vector of bytes (char)...
-1
votes
1answer
60 views

C# Handling Task Cancellations/Timeouts and Exceptions [closed]

I am very new to Tasks and therefore new to handling task cancellations and task exceptions. I wrote this method that gets a List which is then used to populate an ObsservableCollection shown in a ...
3
votes
3answers
109 views

A more functional try…catch construct in Java

I saw a question on Stack Overflow asking for a review of a custom try...catch construct that made use of Optionals, and got the idea to try writing my own version. ...
3
votes
0answers
78 views

Memory managment for RPC code in C

My team has been given care of an old embedded C project. Its main part is a security critical RPC API and I'm trying to create a new design of its internal interfaces to make it more robust against ...
2
votes
2answers
38 views

Lock file and interrupt signals in POSIX shell script running indefinitely

This script is running indefinitely as the Linux background process. I have put an enormous effort to make this POSIX shell script containing an infinite loop shut down tidily along with the ...
3
votes
2answers
82 views

Function to call a list of callables with retry

This script is designed to be run via windows task scheduler once per day. All callables passed to this function should only return a bool. The callables are called until either the maximum number of ...
0
votes
1answer
30 views

Using foldl to add numbers, while validating that they are nonnegative

I have a function that will calculate the sum of a list of integer, however if any of the number is negative, it will should an error instead (not throwing exception). The following is a working ...
1
vote
0answers
28 views

Error handling for an Erlang 2D point class

I am working on a math library for an online game. I want to prevent as many errors as possible and I want to catch all errors as early as possible to simplify debugging in the long run. However, I ...
1
vote
1answer
67 views

Quicksort in C with unit testing framework

This is my quicksort There are many like it but This quicksort is mine. So, quicksort, in C, with a big framework to test it six ways from Sunday. Passed the tests nicely, but there may be warts, or ...
0
votes
2answers
36 views

Printing the status of a database insertion as JSON

The controller is currently inserting a record into the database and returning a JSON response as shown below in the try-catch block. I can see the ...
2
votes
0answers
68 views

Historical exchange rate between currencies using Ecbxrate

I tried writing a simple python script using the python module ecbxrate that outputs to a CSV file a table with the daily exchange rate between EUR and USD since ...
4
votes
2answers
315 views

Reading SQL query from a resource, with error logging

I've created a utility class that expects a logger to be passed at a method level, since I prefer legitimate errors to be written out for troubleshooting later on. Another developer hates passing the ...
1
vote
1answer
896 views

Extension method to to run any async method synchronously

Sometimes I need to call async code from a synchronous method. This leads to repetition in code to wait for the task to complete, then ensure that the expected ...
8
votes
1answer
359 views

A simple ascii progress bar

I've been wanting to experiment with a bit of error handling and robustness to make my code more user friendly. I was inspired by this answer on UX to try and add a progress bar to a button - but was ...
2
votes
1answer
32 views

Testing a probabilistic prime-testing algorithm that may fail

I have implemented Pollard's Rho algorithm in Java. Due to the nature of it there is a small chance for it to fail (have not seen it happening yet). Since I do not ...
2
votes
1answer
74 views

Simple but important function to check and retry given action's result

What I'm trying to achieve is Given a predicate function and an action which returns the object to check, check predicate, retry and fail after numTries .. or success . Purpose of this function ...
-1
votes
1answer
42 views

#Error Handling- Propagating errors to calling function.

Im new to javascript programming and i am required to make a web app. Node.js will be used as the js runtime environment. In order to minimize the amount of time needed for debugging as the app ...
5
votes
3answers
3k views

An exception-safe wrapper for std::stoi

std::stoi may throw exceptions so it needs to be surrounded by try/catch. In applications where std::stoi may be used ...
4
votes
1answer
43 views

Script to clean up old files that should only run one instance

I'm writing a bash script for deleting old files on a Linux server. Here are some relevant facts about this script: As currently written, it does work as expected. However, it's entirely possible ...
1
vote
2answers
83 views

Function to map letters to numbers

I have a method that converts characters to numbers. It expects a single alphabetical character and returns the equivalent number. For example, if A is provided it returns 1, for B it returns 2. If an ...
4
votes
1answer
579 views

Error-Handling Class and Logging for VBA

I've been reusing an error class in Excel VBA projects for a few years now and I'd like to see if there are ways to improve it. Any suggestions for style, code, etc. are all welcome. The 2 ...
1
vote
1answer
175 views

Error-Handling Class and Logging

I am relatively new to C# and would like to see if what I have been using for my exception handling, message and logging is along industry standards. I have created a simple class for the Error ...
4
votes
1answer
58 views

Simple API call to get geo info and exception handling with call limiting to 50 request per hour in Python

I'm looking for a code review of this python I wrote - this code reads the zipcode column value from csv and calls the api and brings back lat, lng, state and city info. It works fine and gives me ...
1
vote
1answer
46 views
0
votes
1answer
44 views

Logging util with static lambda function

So again, I am a bit confused about some notes that i'am getting from my reviewer. I have some kind of utils, to print/prepare log messages. Yea, maybe I am a bit fanatic java 8 lambda guy but I think ...
1
vote
1answer
57 views

Generic error handler function for POSIX shell scripts

Intention I came with the idea of generic, portable, highly reliable, and further customizable function for Shell scripts, written in POSIX, for error handling. Purpose The function shall find out, ...
3
votes
3answers
83 views

Calculate total, minimum, maximum and mean from a set of distances

I have only begun to learn C++ and am reading through the book, "Programming Principles and Practices Using C++". This bit of code is my attempt to complete exercise 3 at the end of chapter 4. The ...
3
votes
1answer
107 views

Given a list of words, remove the shorter word of every pair

This is not a "please do my homework" question. I solved a problem two ways and would like to know which solution is better; better being defined by better readability, lower complexity and lower ...
2
votes
1answer
502 views

WebAPI global exception handler

There is a global exception handler in our WebAPI application that looks like the following: ...