To make the promise catch returns reject, you need to either throw the error or return a rejected promise:
throw new Error('Failed with ' + error);
or
return Promise.reject(new Error('Failed with ' + error));
Then to have report report (as it were) that error, it has to return the promise returned by catch, or return another promise that is resolved to the promise from catch. For instance, if report is an async function, await the result from catch. If it isn't, return that result:
return this.httpClient(reqConfig).catch(function (error) {
console.log("here");t
throw new Error('Failed with' + error);
});
For clarity: You can't make report throw an error from within that catch callback, because report has already returned before that callback runs. (Though if report is an async function, you can write your logic as though it were really throwing the error.)
throw new Error();reportfunction you're talking about. Does it return a promise?