I have Angular on Front – End,
I have a very weird issue:
I am connecting to a Mercure – server events with EventSource in Javascript.
In case of an error for example when I simulate wrong authorization or whatever, the only thing that I receive via browser is:
{isTrusted: true}
I have red this blog: https://blog.sentry.io/what-is-script-error/
And according to the blog and other sources the issue is caused by Browser it is a Script Error.
But I tried catching the error in try catch blog,
I setup the headers according to that article.
This is how the error is handled.
How I can get some normal error format?
this.eventSource.onerror = (error: ErrorEvent): void => {
console.log(error);
if (attempts === 0) {
this._logger
.sendToRemote$({
id: traceId,
log_level: 'ERROR',
log_message: `Mercure connection dropped, after ${EVENT_SOURCE_RECONNECT_ATTEMPTS} failed attempts`,
BODY: JSON.stringify({ message: error.message, fileName: error.filename, lineNumber: error.lineno }),
STEP: 'ERROR',
traceId,
context_data: {
sessionUid
}
})
.pipe(take(1))
.subscribe();
}
if (attempts > 0) {
setTimeout(() => {
this.startEventSource(attempts - 1);
}, 2000);
}
throw error;
};