All Questions
Tagged with exception-handling or error-handling
822 questions
4
votes
1
answer
172
views
Custom 503 page for MySQLi connection error
I redirect all my requests to index.php via htaccess and the code below is in my index.php.
Is this code properly set for a custom 503 page for an unsuccessful MySQLi connection trial?
Is it also ...
1
vote
3
answers
1k
views
Math calculation JavaScript. Am I using Objects correctly? Can I use methods / functions to shorten my code further? Also error logging?
Context- CRM system, front-end form.
Requirement- Within a form users have to give a rating to a section based on user inputs, each rating has different weighting. The rating is stored in an option ...
10
votes
2
answers
2k
views
Robust error handling mechanism in C++ (safer than std::expected)
I've been looking into and experimenting with various paradigms for error handling in C++.
My goals for a robust error handling mechanism would be:
Enforce handling the error cases (in other words, ...
4
votes
1
answer
75
views
Result class to get either value or error
Recently, I had written a Result class. Basically I wanted a function to return result value on success and some error code on failure.
...
1
vote
0
answers
28
views
How to optimize authentication and authorization, API calls in a task management frontend application?
Let me give a brief explanation of the mini-application I've designed using Angular :
A simple login page that requires user email and password as credentials. Once logged in, the user is moved to a ...
2
votes
3
answers
709
views
Capture multiple errors before raising an exception
I have a scenario where I need to store values from some environment variables (names of which I cannot control). My first run at this was pretty basic, however this is not usable as an exception ...
4
votes
3
answers
658
views
Error handling for singly linked list in C
I have seen many list implementations in C in this site; I know its been asked many times. I need some advice regarding:
Quality of my code, especially my list library.
How to handle errors in main (...
4
votes
3
answers
738
views
Implementing strscpy(): Is using errno as a negative return value a bad practice?
strscpy() is similar to the standard strncpy() except that it always writes a valid null-terminated string (unless ...
4
votes
2
answers
941
views
Simple load balancer
I would like to know the possible improvements in design and concurrency of the following load balancer:
ability to add/register new instance
keep max of 10 instances for load balancer
forbid ...
3
votes
2
answers
71
views
Validating a web crawlers page visits with a decorator
I am writing a crawler that is going to end up in production and I was trying to come up with a way to validate its page visits. It scrapes asp.net pages so each scraping process involves a few ...
2
votes
1
answer
87
views
Generic container wrapper type with a default underlying buffer (2nd rev)
This is a revision of the previous question. I was told to ask an additional question with more context for the modified code to be reviewed.
The changes:
changed from ...
5
votes
1
answer
298
views
Generic container wrapper type with a default underlying buffer
I've come up with a type that allows me to encapsulate any container class (that supports std::pmr::polymorphic_allocator<T>) with a buffer and a memory ...
5
votes
2
answers
262
views
Kotlin: scoped functions with try/catch support
I'm working with Kotlin for some time. Compared to Java it's more concise. Still it has some legacy inherited from Java. For example the try-catch-construct. Though it has been upgraded from a ...
3
votes
1
answer
159
views
initializing a timezone database and getting all timezone names (before main())
I have written the below small program that tries to initialize a tzdb before the main() runs. So once the main function runs, it checks the two global variables (...
1
vote
0
answers
54
views
Simple CRUD server in rust
This is my first rust application. I tried to pick somewhat low level dependencies to get a feel for the language particulars.
I'm especially interested in control flow/error patterns in rust as I ...
3
votes
1
answer
81
views
Scraping website with Python and Selenium to collect data from dynamic website
Summary:
The code scrapes the website and collects the data to store it in CSV. It also downloads selected information that is available for download in PDF format. The details and the entire code are ...
2
votes
2
answers
170
views
Checking file header for magic number in Python
I wrote this to check files for successful compression with LZ4.
Any advice is welcome.
Particularly regarding raising exceptions and error handling.
...
2
votes
1
answer
43
views
Understanding how to properly create a stored procedure that only does INSERT from sourcetable to targettable with dynamic sql
Background and use-case
I need to create a stored procedure where the input parameters will be: @sourceTable, @targetTable, @compositeKey. I'm using available fields for the composite key, since I ...
4
votes
2
answers
106
views
TCP socket base class and Winsock implementation
I'm coding a chat application from scratch in modern C++. I'm currently building an interface for interacting with sockets. I want it to be cross platform. Am I approaching platform independence ...
3
votes
0
answers
1k
views
Android APP FTP downloading file implementation in Java
This is a follow-up question for Android APP connect to FTP server in Java and Android APP FTP uploading file implementation in Java. I am attempting to perform the download operation to specified FTP ...
4
votes
1
answer
2k
views
Error handling with C-string input using get() and getline()
I've just learned the basics of c-strings and how to read line oriented input. I noticed that fail bits are set for each function. However, not every problem sends a fail bit, so I thought this would ...
0
votes
1
answer
160
views
Python exception for handling invalid argument types
Greetings
One small problem that anyone have to tackle with in Python is handling invalid argument types ( without an automatic static type checking tool like
Mypy )
One of the best methods for ...
4
votes
2
answers
145
views
Beginner's attempt at TicTacToe
This is my attempt at making a basic TicTacToe game to play against another human player or a computer controlled opponent. The project was a lot harder for me than I initially thought it would be!
I ...
2
votes
3
answers
178
views
Wrap a noexcept C++ library method with a method throwing exceptions with usable explanatory strings to stay DRY
In our apps we're using a shared inhouse library which provides filesystem functions. All the functions are noexcept.
In several apps i found that similar or identical error return translations are ...
3
votes
2
answers
459
views
Hardware API, primarily for Error handling
I have a piece of equipment that I am interacting with. The manufacturer provided an SDK and some simple examples of how to interact with the device. However, I need to write an API for interacting ...
2
votes
1
answer
12k
views
MySQLi query and error handling for select, insert, and update
I am creating a new webpage with database connection. I want to make sure that I am handling the MySQLi query correctly for Search, Insert, and Update. I also want to make sure if any errors do pop up,...
0
votes
1
answer
186
views
Handling exceptions of FileInputStream and XSSFWorkbook
Can you tear my code apart with code review comments?
Below is a simple method which reads an XLSX file and does some stuff with it.
I use FileInputStream and ...
1
vote
1
answer
103
views
Two versions of user-specified exception filters that log a different message on match
I'd like to show you two versions of my two functions that support my logging tools. Their purpose is to log a different message (here abort) when an error occured ...
4
votes
3
answers
2k
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.
...
3
votes
1
answer
210
views
Catching the timed out Exception raised by the __init__ method of the class ftplib.FTP
Introduction
I have written a Python class which uses the module ftplib. In this class I have created a private method called <...
0
votes
1
answer
72
views
C interface exception handling with C++ implementation
Whilst developing a bigger project, I was in need of having basic error handling inside the context of a C interface.
I came up with the following solution.
...
1
vote
1
answer
93
views
Error Reporting in WPF app
I want to add an error reporting feature to my WPF app. I have the view for it created; I just need to know when to call it. I am used to web development and this is my first WPF app.
...
1
vote
1
answer
242
views
A simple parser for bencoding format
I have been learning rust sporadically for a while now and decided to write some toy projects. While browsing https://github.com/codecrafters-io/build-your-own-x I came across some bittorrent client ...
3
votes
2
answers
128
views
Spring boot shop application with error handling
I'm writing a simple online shop using spring boot, for learning purposes. Right now I have purchasing-service and a product-service. The purchasing-service makes requests to the product-service via ...
2
votes
1
answer
113
views
Outcome error handler, inspired by boost's outcome namespace
I'm creating a little library for my pet project that is inspired by Boost's outcome namespace. The main reason why I didn't want to use the Boost version is that I don't like the overhead of ...
8
votes
2
answers
1k
views
Solution to the Rustlings from_into exercise
I've got a working solution to the Rustlings from_into exercise (i.e. the code compiles and all the tests pass). The task required that I implemented the From trait ...
1
vote
1
answer
161
views
Beginner Java Tic-Tac-Toe
I had a Tic Tac Toe assignment for class and the program seems to work fine but I feel like the exception/input handling could be done in a much better way. Is this a good way to approach the ...
11
votes
1
answer
4k
views
Try-except decorator for classmethods
This question is related to the Cactus Text Game Engine.
For easy error handling in Cactus, we've put together this small decorator. Essentially, the decorator wraps any class method in a ...
-3
votes
1
answer
90
views
Catching any exception and actually do something with it [closed]
Say I have a framework, which should catch any exceptions raised from user code, and actually do something with it, such as converting it to a return value
...
5
votes
1
answer
469
views
Write a simple, clean error message without a backtrace and exit on failure
I want to write on failure to either STDOUT or STDERR a clean, simple error message for the user, without the (verbose) ...
3
votes
2
answers
295
views
atomic spinlock mutex class
This here is the follow-up to this question. I was recommended to implement a Lockable type (similar to std::mutex) that can work with ...
3
votes
1
answer
62
views
Cancelling function execution with a ContinuationError
Although throwing excptions for control flow is a controversial topic there are some quite popular examples of using this anti-pattern like C#'s async routines throwing the ...
1
vote
1
answer
392
views
Protecting functions from empty DataFrames
Pandas likes to throw cryptic errors when you feed its functions with empty DataFrames saying nothing that would help you to identify the root cause. In order to ...
1
vote
1
answer
221
views
Function to return a file name from lists/dictionary constants
I'm reworking a set of two functions that return a text file name, constructed from a string argument and string variables from a module called inventory. It seems ...
6
votes
3
answers
4k
views
OOP methods/functions that can return a value or an exception
I'm currently working through a series of bugs in an application. Our application is written in C#/ASP.NET (on the server) and HTML/CSS/JavaScript (on the client). We are using ELMAH to log any ...
5
votes
4
answers
4k
views
Dividing two numbers then handle the divide by zero exception with try/catch
I am new to coding, I hope you can help me to improve my code :)
First of all: The code works correctly.
...
2
votes
2
answers
78
views
Stepwise nested pattern mattching with exceptions
Background
I'm building a lisp-like toy language in Haskell with the following (stripped down) AST:
...
7
votes
3
answers
3k
views
Variant optional to return error string or value
I needed a class with more information than optionals give, I need to know why the optional is not valid in error states. I used a Boost variant for this. Since this will be wrapping almost all of my ...
7
votes
2
answers
816
views
Basic scoped timer struct design
I have written the following simple scoped timer struct in order to help me measure the execution time of arbitrary scopes.
Here is the code (live):
...
2
votes
1
answer
171
views
Command handlers in node.js
Description
This javascript code uses tmi.js to listen for chat messages in a Twitch chat and perform certain actions depending on their content. In the sample code ...