From 0118df08f9754dacfceacd144ff119824fc7734a Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Fri, 1 Nov 2024 01:22:04 -0400 Subject: [PATCH] Let widget driver send error details --- src/stores/widgets/StopGapWidgetDriver.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/stores/widgets/StopGapWidgetDriver.ts b/src/stores/widgets/StopGapWidgetDriver.ts index 07fca154e84..ef55634441e 100644 --- a/src/stores/widgets/StopGapWidgetDriver.ts +++ b/src/stores/widgets/StopGapWidgetDriver.ts @@ -9,6 +9,7 @@ import { Capability, EventDirection, + IMatrixApiError as IWidgetMatrixError, IOpenIDCredentials, IOpenIDUpdate, ISendDelayedEventDetails, @@ -33,6 +34,7 @@ import { ITurnServer as IClientTurnServer, EventType, IContent, + MatrixError, MatrixEvent, Room, Direction, @@ -689,4 +691,15 @@ export class StopGapWidgetDriver extends WidgetDriver { const blob = await response.blob(); return { file: blob }; } + + /** + * Expresses a {@link MatrixError} as a {@link IWidgetMatrixError} + * for use by Widget API error responses. + * @param error The error to handle. + * @returns The error expressed as a {@link IWidgetMatrixError}, + * or undefined if it is not a {@link MatrixError}. + */ + public processError(error: unknown): IWidgetMatrixError | undefined { + return error instanceof MatrixError ? error.asWidgetApiErrorData() : undefined; + } }