My web server could return a custom exception wrapped in a 400 Bad Request object. On the client-side (Angular 9), I have something like this:
return new Promise(resolve => {
this.http.post(...).subscribe(data => {
// ...
resolve(true);
}, err => {
// this is the code that will be executed (400 Bad Request is returned from the server)
this.myService.handleHttpError(err); // prints something friendly to the user; redirects to the previous page
// notice I don't resolve the Promise
})
})
If I resolve the Promise inside the error part, some methods from the method caller are executed (I don't want them to execute). If I don't resolve the Promise it fixes this issue. Do I need to worry about memory & resource leaks or something else?