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.

Filter by
Sorted by
Tagged with
1
vote
1answer
412 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 ...
5
votes
1answer
80 views

Rate-limited geographic data lookup

I'm looking for a code review of this python I wrote - this code reads the zipcode column value from a CSV file and calls an API to retrieve lat, long, state and city info. It works fine and gives me ...
1
vote
1answer
52 views

Exception handling with null check in java

...
0
votes
1answer
50 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 ...
3
votes
2answers
136 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
100 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
173 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
1k views

WebAPI global exception handler

There is a global exception handler in our WebAPI application that looks like the following: ...
5
votes
2answers
3k views

Custom C++ exception class with stack trace generation

I wanted to implement my own runtime error class in C++, that could provide more meaningful information on where the error occurred than std::runtime_error does. I ...
1
vote
2answers
49 views

Error handling for a simple 'fetch some data, then save the data' Node function

This is a fairly simple bit of code: ...
1
vote
1answer
95 views

Spring API that performs RSA encryption with exception handling [closed]

I'm creating a rest api using Spring which utilize javax.crypto as library to do some encryption stuff. While everything works well, I'm curious whether the error handling like this is acceptable or ...
2
votes
1answer
480 views

Retry Class in Java

I have the following Java code used to retry a certain actions/methods ...
1
vote
0answers
139 views

Insert Emojis Into Outlook Email With VBA Application (For those of us who cant use add-ins)

I cannot use add ins here so I set out to create an excel application that could get the job done. I suppose that I could easily transport this into outlook? Basically I want to click one of the ...
2
votes
1answer
348 views

Displaying all application errors in a view

I'm learning ASP.NET Core with MVC pattern and I didn't find anything useful related to this argument. Actually I'm looking ...
3
votes
1answer
122 views

Running SQL Queries On A Worksheet (With Set Of Random Numbers Between 1-20 Filling Column A) Handled As An ADO

INTRO I am using an Excel worksheet as my "database." No headers so [F1] is assigned to column one by default. I filled the entire column, all 1,048,576 ...
8
votes
3answers
1k views

Heap implementation for numeric types

I am trying to improve the quality of my code as well as trying to study the Heap data structure. I have implemented a minHeap (Heap in which minimum value nodes ...
0
votes
1answer
106 views

Python client to fetch JSON data from REST API, retrying on failure

As a beginner, I'd like to see if anyone can suggest any better way of coding the below, as I'm duplicating code and nesting identical if statements as part of the following problem. I'm grabbing ...
0
votes
1answer
169 views

Mechanism to retry failed requests, with throttling

I have a simple event that the client sends to the server, the server can then respond saying if it was successful, or if it failed for some reason. The client has to send a auth code, which is ...
2
votes
2answers
64 views

Parsing date strings, inferring the year such that the date is not in the future

I got this program that I am working on and in it, I got a section that has a try statement and two error except statements. ...
2
votes
1answer
355 views

Executing arbitrary SQL statements using VBA in Excel

I built a workbook to help me extract data from a MSSQL database into Excel. I realize that this is fairly easy to do with Microsoft SQL Server Management Studio, but I can't easily get that installed ...
6
votes
1answer
523 views

Catching missing attribute errors sooner in Python using strict interface specifications

I use Python daily for long-running simulations (yes, very very optimal, I know). As you could probably guess, my coworkers and I have issues with simulations running for several minutes before ...
4
votes
2answers
526 views

Fetching data through HTTP and caching JSON result in a file

The task is to fetch some JSON data from an API with a GET request. If the location is not available for any reason, read a cache file. Otherwise write the cache file for future use. The following ...
4
votes
0answers
204 views

A tree command written in Rust - Error Handling

I am trying to learn Rust as my third main language (Coming from Java/Kotlin and Javascript/Node). For that purpose I reimplemented the Linux tree command. Not ...
6
votes
3answers
12k views

ASP.NET REST controller with try-catch error handling

Yesterday someone guided me through this article and I'm wondering whether I should use try-catch implementation or not? I have the following code below which is actually a RESTful service and I have ...
3
votes
0answers
39 views

Creating chart from data fetched from backend

I have a javascript function written which I think is horrible for multiple reasons (which I have tried to mention in the comments in code below). I want to give it a rewrite following some best ...
-3
votes
1answer
160 views

C++ program involving reading and displaying information from a file? [closed]

This is a program I made for practice in file handling in C++. The purpose of the program is to write three nos 1 2 and 3 into a file abc.dat and then read it and display it on the monitor. When I ...
6
votes
1answer
3k views

Using rotation of proxies within a Python script

I've written a script in Python using rotation of proxies which is able to fetch different titles from a website traversing different pages. I've tried to write this scraper in such a way so that it ...
4
votes
2answers
524 views

Representing multiple errors in Go

The MediaWiki API may return multiple errors. Is this a idiomatic way of representing them? ...
14
votes
3answers
3k views

Custom error-logging

I'm writing a static class to log my application errors into a text file. I am planning on using this as a library on any application I intend to develop in the future. Please let me know how I can ...
2
votes
0answers
26 views

Exception-safety: add cleaning up actions during the execution [closed]

I need to call some functions and clean up some resources acquired after those calls. I can't just call some determined Cleanup function in the end, because during ...
1
vote
0answers
44 views

Rendering server side errors on the client in Node/Express

I've set up a simple Node/Express service that creates new bookmarks to a database. In my Bookmark schema, one of the fields, URL, has validations. When you try to create a new bookmark without the ...
6
votes
2answers
2k views

Customizing errors based on HTTP status code in golang

I want to collect errors and its causes by defining custom errors (HTTP status 40x & 50x). For example, if user's request was bad, I want more specific reasons for the error. A customized error ...
0
votes
1answer
59 views

Using Try & Catch to solve exception [closed]

I am working on a ADDIN that works on 3D drafting program. This ADDIN has historically grown and now I am doing a big rewrite. During this rewrite I came across a issue. I have 2 (fairly similar) ...
3
votes
2answers
9k views

“Always stay connected” mechanism for socket connection

I'm calling Connect() for the first time I connect, I am then checking if the connection is still connected every 10 seconds if it is not connected it attempts to ...
2
votes
0answers
59 views

Catching exceptions arised by different senarios and handle them differently [closed]

I am learning exception handling in java. Every time I am writing a function, I wonder if I should put the entire function code in a try catch block. What the function does: In the below function, i ...
4
votes
1answer
115 views

Resource closing in a promise chain

This is some code that fetches a result from a database. It connects, makes a query, processes the query, then has to close the DB (under all possible code paths) and return the result. It seems ...
6
votes
2answers
131 views

Automated document downloading, with error handling

I've automated downloading of CSVs from our vendors' websites. As expected with anything web-based, things can go... wrong, so I'm implementing some better error handling. The code has been working ...
3
votes
1answer
538 views

Generating a unique reference number for logging purposes in a custom exception

I've come up with a base class for exceptions for this SMS-based service I am working on. The basic idea behind the service is that a user sends a text message to a number, the message requests a ...
1
vote
1answer
154 views

Monkey-patching Jasmine's it() function to log errors

The introduction of async native support in Jasmine doesn't log the errors (i.e., specific line number where the error occurs) to the console. So, to get around this behavior and to make the errors ...
2
votes
4answers
6k views

Correct using of try/catch clause on database execution

When a statement to a DB returns null, I am catching it this way: ...
3
votes
1answer
104 views

Creating a presigned URL

I've created software in Go to create a presigned URL: ...
1
vote
1answer
1k views

Executing multiple async methods synchronously without throwing

I have a following task: execute multiple asynchronous methods synchronously and always execute them all, even when one of them throws. Rethrow thrown exceptions if any occured only after all tasks ...
2
votes
2answers
1k views

Handling FTP exceptions like no internet etc

I'm currently working in a project where the user needs to log in and after that I will check if the directory /cloud/user/Projects exists and if it doesn't, I will create them. The code works, ...
1
vote
1answer
479 views

HTTP download with dynamic reallocation and retries

This code is for downloading a file via winhttp lib, It's invoked by StartDownload function which tries to download n times before returning false if maximum tries ...
6
votes
3answers
233 views

File handling in C

I've created an app to manage students' data which also supports file handling. The Student structure looks like this: ...
2
votes
3answers
127 views

Backing up a file to prevent its corruption during processing

My program is iterating over list of files and processing each of them using some library. It's possible that file might be corrupted in the process so I want to backup it to prevent potential ...
2
votes
1answer
80 views

IsDatabaseUp returns true or throws exception

I want to write an ASP.NET Web API endpoint that allows clients to check if database is running. The method below is check if database is up by establishing a connection and running a dummy sql ...
5
votes
1answer
400 views

Swift function to interpret Roman numerals (ported from JavaScript)

I have written some Swift for the first time, being competent enough in Javascript and having some experience in Ruby and Python. For my education, I've written a function that parses a roman numeral ...
4
votes
1answer
5k views

Find all files in directory and subdirectories while ignoring noncritical exceptions

I need to get a list of all files supported by some libary (images) in a specified directory and all subderictories. Root directory of drive might be chosen and in this case I want to skip system ...
4
votes
1answer
119 views

Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height

I'm trying to find the complexity of this code and some suggestions for improving the code quality. and handling the code gracefully, esp in the areas of exception handling, checking edge cases, ...

1 2 3
4
5
16