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
2
votes
1answer
109 views

How to handle errors from back-end in front-end in different languages?

I have a rest api and a reactjs front end, in some cases, the api will send an error to the front end and I need to display that error. My app will support multiple languages, so the error must be ...
3
votes
5answers
202 views

Dealing with unwanted usages of a function

I am writing a function that I would not like to get called given a certain context and am wondering how best to convey that to possible users of the function. Assume, for exemplification, I am ...
1
vote
1answer
80 views

What is better way to track mistakes in error-prone part of a feature?

That is quite specific circumstances I've come across, and I somewhat struggle to find proper way how to approach this. I'm given a class written in swift-language, which has a control property, like ...
3
votes
1answer
213 views

How to handle failed API calls in C#

I built my API service and now I want to consume the information from a WPF application. So far I created the class ApiHelper which initializes and provides the HttpClient used to call the API ...
1
vote
1answer
107 views

exit and error handling in golang

I am new to Golang and I've seen it is very common to check for errors all the time. I am trying to find a way to not have my code polluted with "if error { log... }" or "if error { exit }". What do ...
4
votes
1answer
478 views

Error handling in Nest service layer

I would like to create a REST API with NestJs. But I want to add GraphQL as another top level layer later on. So for the start I have the basic layers controller, service and TypeORM repository. Let's ...
64
votes
12answers
20k views

Result object vs throwing exceptions

When sending a request to another module and expecting a result, it seems to me there are two ways of dealing with the 'non-happy paths'. Throw an exception Return a result object that wraps ...
1
vote
2answers
65 views

When using data and domain models, where should validation take place? And how should errors be fed back to the user?

When using data and domain models, where does validation take place? Both or just For example: class UsersDB(): def create(self, user_data): # Create user here return ...
0
votes
1answer
24 views

How do I solve the portability of WP_Error?

I wrote a lot of code with the intention of it being usable not only in the WordPress space, but everywhere and because of that, I've been very, very against returning WP_Errors and resorted to only ...
0
votes
1answer
85 views

Handling Failed Rollbacks

To give an arbitrary example, let's say that I'm storing two objects, Item and Box, in the same database. These objects have a one-to-one relationship. Item has the following properties: ID (string)...
2
votes
0answers
99 views

c++ exceptions, should the caller add the context or provide it to the callee?

Here is a piece of code. Basically, I load some source files, all of them are compiled separately, and then I link all of them. LinkedObject loadObject(std::vector<std::string>& fileNames) {...
1
vote
2answers
137 views

Error handling in an event driven system

The context I have two components A & B, which communicate through events . Components B is responsible for long running background processes and it listens to the following event: ...
0
votes
0answers
27 views

Error code handling between Oracle Database and Microservice API

I'm using Oracle Database and .Net Core API for my project. What is the best way / best practice of handling errors between Database and API? What I'm thinking is, I'll return only custom error ...
0
votes
0answers
46 views

Recommendation for design for errorcodes handling

Suppose you are dealing with a situation where you need to handle lot of errorcodes from different server, what would be the design to apply? Suppose 400 is errorcode, sometimes errormessage can vary....
3
votes
4answers
414 views

Alternative to nested-if on single return functions

I'd like to see if there has been any precedent on alternatives to nested-ifs--particularly for error-code returns. My workplace requires one return per function, so I cannot early exit. Here is some ...
1
vote
5answers
342 views

When do I stop being paranoid about my code failing? [closed]

I'm currently designing a system that, no matter how hard I try to break, slow network, failures, random server deaths, it can recover and it can re-build again. Each action it does is a fragment and ...
0
votes
0answers
43 views

Streaming Promises in NodeJS

Imagine a typical HTTP service that does async db queries. If HTTP requests are received more quickly than the db can complete queries (such as because the db disk or network is slow), the Promises ...
2
votes
1answer
98 views

Error Codes with Properties Files or Database

I'm about to implement Error codes for my company API, so, based on rfc7807 I will include a type which is an error type which is basically an error category, and inside those categories we have a ...
1
vote
2answers
279 views

Node.js error handling through each layer

I am looking for a way to handle errors in a Node.js application without getting lots of log entries for the same error event, one from each each affected layer. This might actually apply to any ...
0
votes
1answer
53 views

Sensible way to report errors from cron jobs

I have several jobs that run nightly. Generally they work but from time to time they fail. What's the best way for them to report failure? The way that seems obvious to me is to send email. I have ...
2
votes
2answers
104 views

How do I recover from failed writes?

I'm writing logic for a patchable game, and patching involves modifying multiple files. type UpdateInfo { file string data []byte at int64 } func AtomicUpdate(ui <-chan UpdateInfo) ...
4
votes
1answer
208 views

What's the benefit of avoiding partial functions in Haskell?

AFAIK in Haskell it is heavily recommended to avoid partial functions; and if these seem unavoidable (eg head) then return a Maybe. At least, so the Haskell wiki says 1 2 What's the use of the ...
-1
votes
3answers
227 views

When is it preferable to issue a warning to a user, rather than an error? [closed]

I am writing a semi-complex piece of scientific software. We offer our end users many configuration options for each job and allow users to specify configurations only partially, with reasonable/safe ...
3
votes
1answer
338 views

Managing error code and error message mapping

As part of a game engine I am writing in cython, one of the challenges I am facing is creating a consistent interface for error handling that works at the C and python levels of my code. I am ...
0
votes
1answer
79 views

How to handle errors that is caused by old data structure?

When a major data structure has been changed in an app, what is the best way to handle such kind of errors in the front-end side so that the app doesn’t break? For example, we have a list of users ...
1
vote
2answers
759 views

How to effectively handle 404/500 http errors in server-side rendering web application which uses store for state?

I'm working on a website using server-side rendering approach. I'm using React and Redux for this. Redux handles the state of the application and provides API to change the state. All asynchronous ...
0
votes
0answers
45 views

Patterns for handling a Multi Responsibility Response string

We have an off shore group that is responsible for a SOAP service. The service has a method that returns a key as a string, when everything goes correctly. When it doesn't the key is an error string. ...
0
votes
0answers
24 views

Confidentiality concerns in including all state+actions crash report

I am working on creating a method to send crash report details for an Office Add-In created with Redux. Because of the way Redux works, it is possible to get the entire application's state as well as ...
2
votes
3answers
213 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
41 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
3answers
269 views

Practical way to indicate an error from a function that returns a stuct instance?

Suppose I have a function that returns an instance of a struct with the following declaration: struct data API(void); Suppose also that there is a chance for the function to fail with an error ...
2
votes
2answers
311 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
230 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
154 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 ...
2
votes
2answers
122 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
84 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
145 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
114 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
440 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
176 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 ...
5
votes
4answers
3k 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
58 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
104 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 ...
3
votes
0answers
73 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 ...
2
votes
3answers
418 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
2k 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
2k 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
81 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 ...
1
vote
3answers
454 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
2 3 4 5 6