Skip to main content

All Questions

Filter by
Sorted by
Tagged with
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, ...
golgi apparatus's user avatar
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. ...
kiner_shah's user avatar
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 ...
user285232's user avatar
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 ...
David Gard's user avatar
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 (...
Sai_krishna's user avatar
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 ...
tinyzero4's user avatar
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 ...
ismbks's user avatar
  • 63
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 ...
Gustavo Costa's user avatar
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 ...
digito_evo's user avatar
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 ...
digito_evo's user avatar
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 (...
digito_evo's user avatar
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 ...
intentionally-left-nil's user avatar
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 ...
sangharsh's user avatar
  • 279
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. ...
voices's user avatar
  • 767
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 ...
William's user avatar
  • 21
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 ...
Cherestes Radu's user avatar
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 ...
BenDev21's user avatar
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 ...
KhodeNima's user avatar
  • 399
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 ...
Reslashd's user avatar
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 ...
ridilculous's user avatar
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 ...
LuCio's user avatar
  • 183
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 ...
Michael's user avatar
  • 303
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 ...
AutoTester999's user avatar
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 ...
t3chb0t's user avatar
  • 44.3k
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. ...
Sam Coutteau's user avatar
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 <...
User051209's user avatar
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. ...
Henners2002's user avatar
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 ...
Hakan Sonmez's user avatar
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 ...
Goubermouche's user avatar
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 ...
Drosos-kal's user avatar
-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 ...
user877329's user avatar
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) ...
Timur Shtatland's user avatar
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 ...
digito_evo's user avatar
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 ...
t3chb0t's user avatar
  • 44.3k
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 ...
Dan's user avatar
  • 271
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 ...
t3chb0t's user avatar
  • 44.3k
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. ...
jasmine's user avatar
  • 53
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): ...
digito_evo's user avatar
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 ...
Eoin's user avatar
  • 263
2 votes
4 answers
596 views

CSV to list, map to database

I have a code block that imports CSV to list and map to a database. And there are few validations and I've to return error messages based on those validations. Right now all those logic is handled by ...
Optimus's user avatar
  • 131
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 ...
Patrick Christie's user avatar
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: ...
mingmingrr's user avatar
3 votes
2 answers
154 views

A stripped-down version of UNIX sort utility

Usage: ./usort <options> <filename> Name: ./usort - sort lines of text. Description: Write sorted concatenation of FILE to standard output. ...
Harith's user avatar
  • 9,777
3 votes
1 answer
266 views

Shader Program OpenGL

I am new to OpenGL learning it on amazing website learnopengl.com I wanted to a convenient way to use shader programs thats why I created this struct, please review it. ShaderProgram.h ...
Hrant Nurijanyan's user avatar
0 votes
1 answer
62 views

When to use IllegalStateException [closed]

I am implementing an API that implements an interface, but I do not need to implement all methods. In that case, is it better to just return null or throw an IllegalStateException because it if not ...
Neslihan Bozer's user avatar
2 votes
1 answer
47 views

error tracking in api endpoint

I have built a simple Nuxt 3 app and have some custom api endpoints. I am currently tracking the user query and response statuses to have some insight when something goes wrong and that the app is ...
wittgenstein's user avatar
3 votes
1 answer
157 views

Take in 10 numbers, validate each input, append then in a list and then prints the sum of the list values

I'm practicing loops in Python and started trying to have a better approach with user inputs, is there better ways of dealing with inputs when coding? And I tried using deques too, it worked very well,...
eddyxide's user avatar
  • 141
2 votes
1 answer
83 views

Processing charge current error messages with HashMap<>

I have certain error states that I am displaying in my Android TextView but only one message is displayed at a time and if all values are set to 0, no message is displayed. So, I check all the values ...
Dylon Jaynes's user avatar
0 votes
1 answer
341 views

Google App Script Automation for User Onboarding

Background I am a relatively new developer(> 2 years coding) working as an intern for a smaller company, as part of a now 4 person team. We had two other team members, one our system admin and the ...
RankinJ's user avatar
1 vote
1 answer
88 views

Unit tests for PNGme steganography exercise in Rust

I want to become proficient in Rust and I've followed the PNGme exercise. I've completed it up until Chapter 4 included, where I've written a lot of tests myself for verifying that the command line ...
rdxdkr's user avatar
  • 111

1
2 3 4 5
17