Questions tagged [error-handling]

Questions related to handling errors and exceptions. According to Wikipedia, Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional events requiring special processing – often changing the normal flow of program execution. It is provided by specialized programming language constructs or computer hardware mechanisms.

Filter by
Sorted by
Tagged with
0
votes
0answers
38 views

How do you expose the field that caused the error?

Context: field errors Given an input in the form: { "list": [ { "username": null }, { "username": "test" }, { "username": "" } ] } Some APIs expose errors in the ...
2
votes
3answers
188 views

Dealing with API errors

I'm building a shop system which works in three parts: a mobile app (Android/iOS) which is used by customers to make orders, view products and so on, a desktop application, used by the managers to ...
0
votes
1answer
32 views

Handling different error types from diffierent libraries with express

Most of the express error handling documentation and tutorials I've read suggest using Express middleware to throw errors up to, and to handle the errors there. eg. From the Express documentation: ...
2
votes
2answers
292 views

A way not to forget to check for errors in C

As everybody knows, C allows us to write anything we want. There comes one big problem — we are the only who responsible to handle errors that comes from standard library functions and, therefore, ...
4
votes
1answer
224 views

How to get bug reports without inconveniencing the user

We have a piece of code that looks something like that: std::vector<int> computeGlobalResult() { auto globalResult = std::vector<int>{}; while (myCollection.size() < 100) ...
2
votes
2answers
137 views

How to create useful error messages in a JSON REST API without leaking implementation details across layers?

We're implementing a REST service with three main layers: Controller, Domain, Repository. The REST API is supposed to respond to error conditions with meaningful error messages. Suppose the general ...
1
vote
1answer
59 views

How to design sequential requests to third-party APIs?

I need to implement the following flow: Back-end makes HTTP request to Service A, waits for a response from Service A, then makes HTTP request to Service B, waits for a response, then makes ...
0
votes
1answer
70 views

Types of errors that the primitive operators in C might be involved in

I am new to C and wondering how to properly build primitive functions in order to handle errors. Take for example the following function: bool testIfEqual(int a, int b) { return a == b; } ...
0
votes
2answers
142 views

Should I track my handled exceptions?

Various analytics tools will track the number of handled and unhandled exceptions (crashes) that happen in an app. This obviously helps us find problems we didn't know existed and will fix it. Quite ...
0
votes
1answer
89 views

Chain function calls which return error codes or 0 on success in C [closed]

I used to call functions which returns int error code or 0 on success like this: int tmp = function_a() ?: function_b() ?: function_c(); if (tmp) handle_error(); Now I'm ...
1
vote
3answers
335 views

Is avoiding throwing an exceptions OK?

e.g I'm parsing whole Excel file with many rows, that has an column which contains Date. I'm not sure how to handle error-handling when it comes to parsing string to DateTime Here's an sample code ...
1
vote
2answers
140 views

Dealing with minor, non-critical errors (warnings) in libraries

I'm writing a small library to open an xml. If reading top level xml element fails, the library throws an exception. However, if reading one of the minor, lower level xml elemetns fail, I currently ...
3
votes
4answers
739 views

Should you retry 500 API errors?

My team and I are integrating with a 3rd party company and using their API to perform different CRUD operations. Their API isn't always reliable though. Maybe 0.1% of the time an API call just fails ...
-1
votes
1answer
53 views

Difference in use-cases for just using '.catch' v.s using 'Throw Error…' with '.catch'

If .catch catches any errors upon request attempt, why would I need to use Throw Error... with .catch? For instance, what is the throw Error used for, that the .catch doesn't handle automatically? ...
1
vote
2answers
189 views

Error Monitoring On The Apps Which I'm Selling

I'm developing JS and PHP scripts and selling them on various marketplaces. But I need to track/monitor errors on my scripts. Usually, I use Sentry for own web apps, but I'm not sure if it's okay to ...
1
vote
1answer
101 views

Making type conversions better readable

If you create a function, which should make the use of typeconversions more easy, but it maybe leads to more errors, would implement it globally, and what may speaks against it - when the readability ...
2
votes
0answers
67 views

What're the necessary considerations when developing Cron Jobs (Scheduled Tasks)

I'm working on a website that has a section that shows the company's stock details and investor-related data. This data is retrieved through scheduled SOAP API calls. I created two scheduled tasks ...
1
vote
3answers
134 views

Catch statements with other Business Logic in Parsing Files

I am writing a simple program to parse a text file and place into Generic List. Sample Text: 1,Joe,CA,58,2 2,Matt,TX,63,5 Sometimes, there may be an error, with missing data in the file 1,Joe,CA,...
3
votes
4answers
853 views

Command handling fail feedback with CQRS

We are developing some context using CQRS approach. We have ended up with command handlers emitting events. It seems to be not a good idea to us. However we can't find any alternative approach. We ...
2
votes
2answers
709 views

How to integration test server failures (http 500)

Like in the title: how do you integration-test server failures that return 500 HTTP responses? For example: There's a server with a /save endpoint that accepts files on POST and saves it into the ...
1
vote
0answers
67 views

Should I implement a JAX-RS ExceptionMapper for java.lang.Error?

I have a Jersey server that handles REST requests where I've implemented a RuntimeExceptionsMapper implements ExceptionMapper<RuntimeException>. If there's an unexpected exception, it handles it ...
0
votes
3answers
102 views

Error Handling Best Practice for External Library

My development environment specifically is .NET and I'm writing a DLL to be compiled and referenced in other .NET programs we'll be writing going forward. My question is: In that DLL, what is the ...
-1
votes
2answers
73 views

How to structure an application (and its user interface) such that extraneous and/or malformed data can be handled?

I recently applied for a position as a software developer. As a part of the recruitment process, I was given an assignment that involves reading data from a file. The thing is that the example file ...
5
votes
3answers
188 views

How to handle repetitive mallocs/frees in a DRY way in C

So I have a function which is like a constructor for my structure: MyStructure* CreateMyStructure(...) { MyStructure *my_structure; double *data; int *colind, *rowptrs; data = malloc(...
-3
votes
1answer
489 views

How to deal with errors in a distributed system

In my experience, most errors in an application are bugs: Syntax Error Range Error (number out of bounds) Reference Error (undefined variable used) Type Error Custom Assertions These should be ...
1
vote
2answers
421 views

Is it okay to put all your error handling on facade layer?

I am doing a Java Spring-Boot backend project and I am implementing a controller-facade-service pattern on my structure. So is it best to put all my error handling on the facade layer, while the ...
2
votes
3answers
364 views

In languages without exception-handling, should error codes be returned from the function or in function parameters?

I'm writing a CSV parsing library in C and am considering whether to express error codes as return values or as parameters passed by reference. For example, here are the signatures for the function ...
1
vote
1answer
89 views

Design: HTTP and Websockets working together

I'm at a bit of crossroads here and I wanted to ask the opinion of the community. I am creating a chat application for our company. Now, like every chat application out there, the messages are saved ...
12
votes
5answers
5k views

Should service throw exception or return when no items specified for deletion

I have a piece of code that can be represented as: public class ItemService { public void DeleteItems(IEnumerable<Item> items) { // Save us from possible NullReferenceException ...
3
votes
3answers
267 views

Handling domain errors in the API

I'm working on building an API interface on-top of a domain-driven architecture. The domain layer has a bunch of specific exception classes (i.e. NameIsRequiredException, CannotPublishDraftException, ...
4
votes
2answers
214 views

Should I retry a query that failed because of a connection error?

Let's say I want to add a row to a table. I send the query from the client (the website, not the user) to the database which is on another physical server. The query is sent over the network. The ...
3
votes
1answer
142 views

What is the standard method of handling errors in a NodeJS web app?

I am currently working on a web application as a learning project, which has a NodeJS backend and uses a MongoDB database; however, I believe my question is not specific to the technologies I am using....
38
votes
11answers
34k views

Should a REST API return a 500 Internal Server Error to indicate that a query references an object that does not exist?

I am working with a REST API which resides on a server that handles data for a multitude of IoT devices. My task is to query the server using the API to collect specific performance information about ...
1
vote
2answers
395 views

What's the best approach to handle errors and ensure software robustness? [closed]

I am developing a new desktop application from scratch using C#, before opening the visual studio and start typing in the keyboard I want to prepare a solid design for my software. The main challenge ...
6
votes
5answers
492 views

Message validation in async messaging-based services

I'm looking for information on the best approach to message validation in asynchronous-messaging-based services (i.e. services that pull messages from some sort of message queue or broker, rather than ...
1
vote
3answers
394 views

Should a file reader library API throw exceptions?

I am developing a (Java) library providing an API to read a file in a specific format into an object. The format is basically a map, and specifies valid values for some of the keys, and valid types ...
1
vote
2answers
773 views

How should I handle error codes from an external XML API?

Problem I have a Python library which sends XML requests to an external API. If an issue occurs, the API responds with an error containing an error code and description with error details. These ...
7
votes
2answers
3k views

Handling error messages from others services in Micro Service Architecture

Our company runs applications on a Micro Service architecture that includes thousands of services. I am working on a backend application "X" that talks to 50+ services. Frontend services call my ...
5
votes
1answer
641 views

How to deal with failing messages in DDD?

We have a set of micro-services all built according to the Domain Driven Design (DDD). The micro-services communicate via Domain Events with each other (OrderSubmittedEvent, CustomerBilledEvent, ...). ...
0
votes
1answer
215 views

Adding error handling to a function (which sometimes should throw an error and sometimes use a default value)

I'm trying to add error handling to a function that reads data from a DataSource (which performs all the parsing etc. required). Unfortunately (due to a lack of versioning until now) some of the ...
2
votes
1answer
396 views

Not prohibited, but disallowed — which http error code should I return?

I know that if user is forbidden in an admin's area, I should return 401 or 403 status error code. However, what I want to prohibit an admin for accessing a user's dashboard also? An admin has its own ...
4
votes
2answers
1k views

Error handling and exceptions in a layered (or onion) architecture [closed]

Given an onion architecture, what are the advantages and disadvantages of throwing exceptions in the business logic (which is in the center of the onion) for invalid parameters provided by the user? ...
-7
votes
1answer
103 views

My project shows errors unexpectedly. Is there a good method that can be used to plan a project before starting and deploying it? [closed]

I have completed a project. But errors unexpectedly occurs anytime when the user inputs data in it. Yesterday my program was performing very well. But today when the client tested the project it had ...
16
votes
2answers
5k views

Multi-Layered Architecture: where I should implement the error logging \ handling?

I'm currently refactoring a large subsystem with a multi layered architecture, and I'm struggling to design an effective error logging \ handling strategy. Let's say that my architecture consists of ...
4
votes
1answer
51 views

Should error/ack message be constructed in the client or in server?

Should messages that will be shown to the client be resolved in the client-side or in the server-side? Any design (dis)advantages that you can think of between the two approaches? If the system ...
2
votes
4answers
2k views

How do I return an error from a boolean function in C?

I'm working on a little pet program in C where I have a game board that consists of a bunch of squares: typedef struct _square { bool checked; } Square; typedef struct _board { Square *...
1
vote
1answer
103 views

Catching base Exception to preserve data integrity

I know that often catching all exceptions (C#: catch(Exception exception){...}) is deemed bad practice. However, I believe that there are situations where it is perfectly reasonable to do it. For ...
4
votes
1answer
172 views

Proper way of throwing errors in a JavaScript library?

Let's say I am writing a simple library in JavaScript, with only a few functions: Calculate the factorial of a positive natural number Find the least common multiple from an array of integers And so ...
2
votes
5answers
863 views

Handling errors for non-exceptional cases in modern C++

To hone my skills - and for the pleasure of it - I am writing a small game for my kids in modern C++ (C++11, C++14 and the part of C++17 already supported by Visual Studio), which is a nice break from ...
23
votes
3answers
13k views

In C#, why are variables declared inside a try block limited in scope?

I want to add error handling to: var firstVariable = 1; var secondVariable = firstVariable; The below won't compile: try { var firstVariable = 1; } catch {} try { var secondVariable = ...