mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
prevent errors in promises from being uncaught
by returning a promise that has the error swallowed
This commit is contained in:
parent
80be2b7457
commit
29a7b0451e
@ -49,9 +49,12 @@ export class ErrorReportViewModel<O extends Options = Options> extends ViewModel
|
||||
|
||||
protected logAndCatch<T>(labelOrValues: LabelOrValues, callback: LogCallback<T>, errorValue: T = undefined as unknown as T): T {
|
||||
try {
|
||||
const result = this.logger.run(labelOrValues, callback);
|
||||
let result = this.logger.run(labelOrValues, callback);
|
||||
if (result instanceof Promise) {
|
||||
result.catch(err => this.reportError(err));
|
||||
result = result.catch(err => {
|
||||
this.reportError(err);
|
||||
return errorValue;
|
||||
}) as unknown as T;
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user