All Questions
Tagged with exception-handling or error-handling
822 questions
2
votes
1
answer
83
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 ...
3
votes
2
answers
156
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 ...
4
votes
1
answer
1k
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 ...
1
vote
1
answer
63
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 ...
5
votes
3
answers
1k
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. ...
5
votes
1
answer
9k
views
Ruby selenium script waiting for an element to disappear
I'm a Java developer, I'm new to Ruby and I'm worried that I'm forcing or not-so-well using the goodness of the Ruby syntax.
What do you think about the Exception catching and how to print it in ...
4
votes
2
answers
238
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
3
answers
211
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.
...
5
votes
2
answers
132
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
1
answer
89
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
3
answers
1k
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
0
answers
102
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:
...
2
votes
1
answer
6k
views
Extension method 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 ...
-3
votes
3
answers
86
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
2
answers
304
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
...
2
votes
2
answers
4k
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
1
answer
70
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.
...
5
votes
2
answers
312
views
URL decode a string but log an error after second exception
I have a method which does URL decoding on the string value passed along with using Charset:
...
1
vote
1
answer
737
views
4
votes
1
answer
2k
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
...
3
votes
1
answer
332
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
1
answer
136
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
1
answer
1k
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 <...
4
votes
1
answer
322
views
Notify user of credential failure and make another attempt
The below code works because of the do operator on line 24. Is there a more functional way to get the test to pass, or would you consider this an appropriate use of ...
2
votes
1
answer
55
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
3
answers
3k
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
vote
1
answer
65
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:
...
-1
votes
1
answer
39
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
2
answers
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
0
answers
799
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
1
answer
335
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
1
answer
57
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 ...
3
votes
2
answers
520
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
2
answers
162
views
JSON fetcher for Eclipse plugin
This is a client module of an Eclipse plugin. I am planning to use this code as a "good exception handling" code example in one of my papers. How does it look?
...
5
votes
1
answer
5k
views
SemaphoreSlim extension method for safely handling cancellation and disposal
I have often found myself using a try {semaphore.Wait()} finally {semaphore.Release()} pattern when using a semaphore, so decided I wanted to try and write an ...
2
votes
1
answer
245
views
Should I re-throw exceptions within a method, or is there a better way to handle it? [closed]
When handling errors in C#, is it acceptable/appropriate to re-throw exceptions that are caught in a try/catch?
My scenario is that I am making an HTTP request and ...
3
votes
0
answers
46
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 ...
4
votes
1
answer
5k
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 ...
3
votes
0
answers
25
views
A XMLHttp Request in the browser
Building on a previous answer and an attempt to write a comprehensive XMLHttpRequest example that covers all kinds of possible errors and return them to caller ...
3
votes
2
answers
4k
views
Timeout implementation of fetch
After doing some research on google i didn't find any good info on how to implement timeout with fetch (looks like there are multiple proposals but that's about it so nothing has implemented it). For ...
8
votes
2
answers
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
1
answer
151
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
2
answers
1k
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?
...
3
votes
1
answer
526
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
2
answers
638
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
1
answer
520
views
Blocking requests within Express
Is this the correct way to block requests in Express?
app.js
...
2
votes
2
answers
2k
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, ...
5
votes
1
answer
87
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 ...
7
votes
0
answers
249
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 ...
12
votes
1
answer
721
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 ...