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
29 views

Part 2: Send HTTP request for each row in Excel table

This script was previously reviewed here: Send HTTP request for each row in Excel table (Part 1) I've made the changes that were suggested in the Code Review answers as well as added a few of my own. ...
2
votes
1answer
57 views

C# Reflection-based CSV Parser

I've been trying to make a C# version of my Java CSV Parser using C# specific idioms. Here is the full code: ...
3
votes
2answers
67 views

Tic-Tac-Toe in Java

I am currently learning Java; I could really use some help from more experienced programmers. How can I clean up my Tic-Tac-Toe code? What mistakes have I made? Can I use more exception handling? I ...
1
vote
0answers
17 views

Is there a better way to handle errors in these functions?

I'm creating a GOLang Linux distribution installer. The architecture is straight forward. I have N parameters and uses them in N installation steps. Summarizing: Every step implements a interface ...
5
votes
2answers
362 views

C++ custom exception class

I am wondering, how can I improve this simple MissingResource exception class? I am using it in my simple game. ...
1
vote
1answer
43 views

Handling multiple try-catches in a for loop

Good day! I would like to know if this is possible to be refactored into a cleaner code. The reason I'm doing it like this is to catch the column that the error appeared on and then potentially output ...
4
votes
0answers
22 views

Error handling best practices using a custom error handling module

I am trying to learn how to effectively use error handling in my code. To do this, I have created a class inside main.py which reads the value of a specified curve ...
1
vote
0answers
39 views

One of my first Bash scripts - checking for best practice and error handling

I have a Bash script that resides on Remote Server A and transfers files from Remote Server 1 to Remote Server 2. Remote Server 2 is a Dropbox folder so in this script, I call another script (that's ...
0
votes
2answers
41 views

Bugs - Program that Creates a Directory in C

I have the following code that creates a directory in C. I tested it multiple times, reviewed it a few times and it looks fine at the moment. What I really wanna know is what bugs does it have and ...
1
vote
1answer
60 views

Code for adding a user to the database

I have a code that adds a user to the database, getting the username from the dialog.My fragment implements the interface with the onInputSend method, which is called by the dialog when the user ...
1
vote
1answer
44 views

Best way to avoid users to cancel my routine halfway through while managing other errors

I'm struggling to find the best way to prevent users from cancelling a routine halfway through (by pressing ESC, break, etc) without making sure the sheet is being locked again. On top of that, I also ...
4
votes
2answers
223 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
78 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
53 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
66 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
69 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
69 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
52 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
29 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
159 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
65 views
4
votes
1answer
230 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
38 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
56 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, ...
6
votes
1answer
183 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
2answers
48 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
35 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
80 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
531 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
31 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
1k 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
77 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
376 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
109 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
243 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
379 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
43 views

Blocking requests within Express

Is this the correct way to block requests in Express? app.js ...
4
votes
3answers
132 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
47 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
134 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
158 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
38 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
2 3 4 5
15