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
4
votes
2answers
151 views

Reader for graph-file with ugly return and questionable use of streams

I wrote a class that contains a static method that reads in files from NetworkRepository and converts them into a list of integer-arrays, each representing an edge. The file format from ...
4
votes
1answer
72 views

How to stop a Python script if the input values do not make sense within the environment in which they will be analyzed?

I am not a developer, but I needed to write a script. So I wrote it. Since I can't find an accessible tool that fulfills the same purpose, which I think may be helpful to others, I decided to ...
1
vote
3answers
50 views

Custom exception handling function or logging library?

I want to document every exception handled in my code and some states of the code when it works properly. What I've done is two functions, one that creates an 'error report' (function: ...
3
votes
0answers
64 views

HTTP download function in Rust (async/await)

Why am I fighting the compiler? - Wrote this, which works, but I feel like I'm breaking every rule in the book: ...
-3
votes
3answers
68 views

Opinion on Python exceptions? [closed]

Just looking for opinions on which is the best way to use exceptions? Should the exception handling go inside the function or should it go outside the function when you actually call the function. ...
2
votes
2answers
66 views

Shared memory class

I wrote a class that opens a shared memory communication to use in my project, and would like a review. mylib_com.hpp ...
1
vote
1answer
50 views

File handling with try and except [closed]

I am learning programming with Python. I am not sure if I can write a try/except block like this. ...
2
votes
0answers
26 views

Best way to catch API errors and log responses when calling via helper function

I'm trying to add error handling and response logging for API calls. The way I have my application (chatbot) set up is that a helper function is called from the main dialog, and that helper function ...
2
votes
2answers
123 views

Right way to handle, log and display exceptions

I repost my question here because it has been closed on stack overflow This question could sound stupid but I am new to the logging, displaying and handling exceptions. Because before I was just ...
1
vote
1answer
61 views
4
votes
1answer
155 views

Minesweeper - Python 3 (beginner)

I’ve just created Minesweeper game, which work perfectly fine (for me). Any suggestions on how to improve this code would be greatly appreciate, in terms of: Object-oriented Array Error handling ...
2
votes
1answer
35 views

Java: Only log first error occurrence (with hourly reset)

I have a redis caching server. If that caching server is down, my app will query the database directly. I want to know from the logs if my caching server is not reachable. However, if I add a log ...
-2
votes
1answer
55 views

Is it good practice to use try catch only for a part of the code [closed]

When I submit the form, I need to validate the input data from an HTML form field, which comes from the user who submitted the data. So inside the Page_Load event, ...
5
votes
1answer
121 views

c# Factory Pattern Generic Exception Handler using dot net core

My task was to create exception handler on some system that has multiple types of database and big business behavior. At first, I had done a switch/case that handled the exceptions by type using the <...
0
votes
0answers
28 views

Python exception handler

Here's a fictitious program to throw an exception, plus my standard exception handler (for Python 3.x), which I would like to have reviewed. In particular, is there any more data that I can include ...
2
votes
1answer
33 views

PowerShell script creates a computer list from an AD OU, and add exclusions to a specific file via Invoke-Command

My code is working, however, in the foreach section, when it runs the invoke-command if I don't use "-ErrorAction SilentlyContinue" the red error text that states a computer cannot be connected to ...
2
votes
1answer
32 views

Naive SCP module in Elixir

I'm trying to do a simple implementation of a scp wrapper in Elixir. The code is working as intended, but I got a feeling that the error conditions can be ...
3
votes
3answers
77 views

Recursive Error Handling in Python with a limited amount of tries

I have a class method that is set up to make requests to an API and I'm having issues handling the possible errors that could arise by trying to communicate with that server. The idea is if an error ...
-1
votes
1answer
29 views

Provide one file where all error messages are defined in c++ [closed]

I would like to store all error messages in one file and call them for example with ...
2
votes
2answers
401 views

Beginning BMI calculator in Java

This is my first program so no doubt I've made mistakes. The code works and meets all requirements as far as I can see. (Further info: program to calculate Body Mass Index (BMI) allowing user to ...
2
votes
0answers
54 views

Implementation of SCPI for control of test instruments

I work with electronics test equipment. I like to be able to automate tests using their remote control interfaces. I have built a pattern, a few base classes, that I can apply to all devices that ...
7
votes
1answer
234 views

Interpret a date from a string of digits

I developed a function that, from a given sequence of digits, extracts the date and reformat it. This is the code: ...
1
vote
1answer
46 views

Handling errors in an input based program

I wrote a program which creates a svg-group that contains several arranged rectangles with passages inbetween to reach all of the rectangles inside of an area selected by the user. Each rectangle ...
0
votes
0answers
30 views

Error handling in Go

I have a function which returns an error. I would like to handle this error on the caller function, so I need to know the reason of the error in the caller function. Below there is my solution, but I ...
4
votes
1answer
1k views

Asynchronous parallel ForEach implemented using Task.Run

I wrote a simple implementation of aysnc parallel.ForEach( ... ) All it really does is create a list of tasks and wait for them all to complete and aggregate the ...
7
votes
2answers
995 views

Python implementation of atoi

I made an implementation of atoi (ascii to integer) in Python a while ago for fun, and I'd like to know what I could do to improve it. ...
1
vote
1answer
74 views

Connect to database, handling errors

I try to handle or catch possible errors with PHP/MySQL for security reasons and would like to know if I'm doing it right. The first case, connection: I use it as a function and call it always when ...
5
votes
2answers
366 views

Single vs Multiple Try Catch

I have this code which is a third-party transfer for ATM console app. For best practice, should I just put all the code into one try block or with multiply try block like below? ...
5
votes
2answers
106 views

A simple but useful error handler

I am trying to make a very simple error handler that would catch and handle all kinds of errors in both development and production environments. The idea is to keep it as simple as possible yet useful ...
3
votes
1answer
223 views

Poor error handling: Throw inside Finally

I have the following code which I am running through fortify. Why it gets marked for poor error handling, throw inside finally? ...
7
votes
2answers
361 views

Network helper class with retry logic on failure

I wrote an helper class which allow me to request the body content from a site that is created by AJAX, for doing so I'm using <...
2
votes
1answer
42 views

Blocking requests within Express

Is this the correct way to block requests in Express? app.js ...
4
votes
3answers
125 views

PHP display Error Wanings Yellow @ bottom of Page with PHP_EOL

I initially started searching for a PHP script which would output PHP errors, to the JavaScript console. As the Default behaviour is just to spit them out anywhere and displace everything else. ...
1
vote
1answer
46 views

Clean up code that transfers data from DB2 Server to Excel

The code below is functional and works as expected, but I imagine there is a better way to test for the error that I am testing for . The scenario is that data is transferred between two different ...
2
votes
1answer
99 views

Go functions to create a directory if it doesn't exist

Which of the 2 solutions is written better? Personally I prefer the one line method but it does make it slightly more difficult to debug. Is perhaps doing it the long way first then refactoring to ...
12
votes
3answers
5k views

C# TCP server/client class

Goal My goal is to create a TCP server/client class that can be universally reused in various private projects. It should work stable and does not need to be super fast, but rather light-weight to ...
10
votes
1answer
137 views

error-specific tryCatch

R doesn't have classed errors, just (for the most part) error and warning, so determining if the error should be caught or ...
2
votes
1answer
58 views

PHP function to check if something valid or return error message [closed]

I would like to make a function that checks if something is valid, but if it can't then I want to return an error message that will probably be used to to throw an exception. ...
3
votes
1answer
37 views

Validating partially filled objects

The following classes are a simplification of an auto-generated code of an ORM (targeting Microsoft's Dynamics CRM): ...
-1
votes
1answer
147 views

Try-catch-finally snippet [closed]

Using visual studio I created a snippet which helps me surround my already written or new code into a try-catch-finally block. I use axios for REST so there had to be separate error handling method so ...
2
votes
2answers
109 views

Jsoup connection to URL

I have simple class that I want to ask if is there any possible to improve it? I mean, for me it looks poor. Is there any way to use here try-with-resources, stream or ...
1
vote
0answers
72 views

AWS plugin to create a CloudFormation stack if it doesn't exist

The following Python class is what I am trying to refactor in the case where I have to add validation of the existence of an AWS cloudformation stack before creating it in the method create_cfn_stack :...
2
votes
0answers
21 views

Error handling in express without middlewares and using class structure

This is a simple implementation of Django's sample project "Poll" using and express. The controller code: ...
5
votes
1answer
127 views

Detecting the presence of multiple URL segments

I have two versions of a function that performs the same task, however I'm not sure which one to use. Speed is something to take into consideration, but I also want to know what the best practice is. ...
3
votes
3answers
1k views

Go function to test whether a file exists [closed]

How could one write in a more elegant way that if error is null, the result is true? I really need a bool as returned value. ...
4
votes
1answer
53 views

Send / receive wrapper for System.Net.Sockets - follow-up

I recently posted a question about improving thread and socket safety in my NetworkEndpoint class. previous post I have implemented the changes suggested in the answer I got there. When I asked for a ...
1
vote
1answer
35 views

Enumerating AWS instances in Rails, with error handling

I have created a method, which is raising the same exception in case of any error: ...
7
votes
3answers
541 views

Compiling all Exception messages into a string

Below is a recursive function I've written that's responsible for compiling a string consisting of a Exception's message, and also each of that ...
6
votes
1answer
114 views

Send / receive wrapper for System.Net.Sockets

The following NetworkEndpoint class serves as a simple send / receive interface for either side of a network connection (client or server) when provided with a ...
10
votes
4answers
1k views

Skipping over failed imports until they are needed (if ever)

We have a program with many dependencies. Because the user may not want to use all of them, the program should skip over failed imports and only raise an error if absolutely necessary. e.g. if the ...

1
2 3 4 5
15