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
-3
votes
3answers
75 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
81 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
56 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
33 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
735 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
112 views
4
votes
1answer
751 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
67 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
59 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
441 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 <...
5
votes
1answer
149 views

Handling exceptions in Python 3

Please can you review my standard exception handler for Python 3.x. It is located under the # +=+= line. The code above the line is to create an exception and so ...
3
votes
2answers
56 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
40 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
150 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
31 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
1k 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
64 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
237 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
32 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
3k 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
2k 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
86 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
413 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
112 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
348 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
429 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
75 views

Blocking requests within Express

Is this the correct way to block requests in Express? app.js ...
4
votes
3answers
165 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
50 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
352 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 ...
13
votes
3answers
7k 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
289 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
61 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
40 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
338 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
252 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
81 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
22 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
128 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
57 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
48 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
666 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
163 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
2k 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 ...
3
votes
1answer
291 views

PHP Error handler class

I set up an error handler class to handle all server errors, I know there are already quite a few out there, but I like creating my own for better learning and understanding of how things work. I am ...
-4
votes
1answer
1k views

What is wrong with my 'except' code here? [closed]

I am learning python and am working through some try and except codes. What is wrong here? The code aims to convert the input ...
3
votes
0answers
130 views

msmq bulk send in c# [closed]

Please review the code below and provide constructive feedback to improve. Multiple threads call the SendMessageToMSMQ method to send messages to a msmq queue. ...
2
votes
0answers
21 views

Thread safe Shareable and Splittable Buffer with Safe Memory (Project)

Backstory This is a buffer I wrote for use in multiple personal projects. It is designed to handle pretty much any data in pretty much any way. In particular I intend to use it in such instances as ...

1
2
3 4 5
16