Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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 ...

2
votes
3answers
160 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
52 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
187 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
94 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
62 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
86 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,...
2
votes
4answers
292 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
224 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
38 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
65 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
176 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
146 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
256 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
289 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
69 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
4k 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
134 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, ...
5
votes
2answers
130 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
141 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....
37
votes
11answers
21k 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
275 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
301 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
249 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
619 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 ...
6
votes
2answers
1k 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
514 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
211 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
359 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 ...
3
votes
2answers
569 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? ...
-6
votes
1answer
91 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 ...
13
votes
2answers
2k 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
49 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
1k 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
88 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
169 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
708 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
11k 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 = ...
0
votes
1answer
58 views

Disambiguating errors for the same HTTP status code

Assume I have two different error cases that logically have the same HTTP status code. What's the canonical way of providing data dependent on the error case in the response so that clients can ...
10
votes
4answers
355 views

Include a link to relevant documentation in error message?

We create a commercial library and code examples that are being used by external developers. We have (closed, available to registered users) documentation that extensively explains how to use the ...
0
votes
1answer
66 views

Redesign factory to throw error on load time instead of on execution time

I am using a factory pattern to get objects that shouldn't be instantiated other than the factory class. These objects are of type ViolationType, which represent violations on a set of rule. Here is ...
0
votes
1answer
546 views

Upstreaming microservices errors

As per the microservice architecure, there should be one codebase per microservice with no shared API whatsoever. This enforces a high level of decoupling and every microservice is bounded within its ...
0
votes
2answers
2k views

Handling errors in a client/server application

I am developing a web application and struggling to follow a clear semantic while returning response to the client. Taking an example of authenticating an user there can be following scenarios: 1. ...
3
votes
2answers
743 views

How to deal with HRESULT spaghetti?

I'm currently writing an audio application using WASAPI, which is a really great learning experience, however I have this odd problem, I don't really know what to do about all these HRESULT codes in a ...
1
vote
1answer
96 views

Is it correct to only test for database connectivity failure on the login page/form?

There is a database-based application at work with an authorization system. If a user is not logged in, the only system accessible to them is the authorization system where they must provide a valid ...
2
votes
2answers
338 views

Augment a thrown exception with some contextual information

The application this question is about is basically a transpiler which contains a lot of logic. The transpiler is written in C++ (which should not be much of relevance for this question), and it ...
-1
votes
1answer
38 views

Working On Remote Errors in a Variety of Environments Without FTP or SSH Access

BACKGROUND: I've been developing in PHP for two years - self taught, and beyond the most basic editing, really just a year and a half - but my experience is limited to a small number of environments. ...
0
votes
3answers
831 views

When to use asserts vs unit tests or both?

Background: I'm creating my first C++ game project and I plan on calling a InitialThirdPartySystems() function to...well...intialize all third party systems to be used in my code lol. Within it I ...
14
votes
3answers
3k views

How to handle post-validation errors in command (DDD + CQRS)

For example, when you submit a Register form, you have to check in the Domain Model (WriteModel in CQRS) that it is in a valid state (example, email address syntax, age, etc). Then you create a ...
3
votes
1answer
410 views

What is the best way to pass errors between PHP pages?

I had some ideas, but which one is the best (and why), and is it other way(s) to do this? I thought about : - Sessions - GET Params, but if there is a lot of errors(for example a register form) ...