Skip to content

Commit c8c1074

Browse files
authored
Let widget driver send error details (#28357)
* Let widget driver send error details * Match new widget API types * Don't @link across packages in case web documentation generation disallows it. * Update matrix-widget-api * Update matrix-js-sdk Include matrix-org/matrix-js-sdk#4507 to fix playwright CI
1 parent 17de661 commit c8c1074

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"matrix-encrypt-attachment": "^1.0.3",
128128
"matrix-events-sdk": "0.0.1",
129129
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",
130-
"matrix-widget-api": "^1.9.0",
130+
"matrix-widget-api": "^1.10.0",
131131
"memoize-one": "^6.0.0",
132132
"oidc-client-ts": "^3.0.1",
133133
"opus-recorder": "^8.0.3",

src/stores/widgets/StopGapWidgetDriver.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
WidgetDriver,
2525
WidgetEventCapability,
2626
WidgetKind,
27+
IWidgetApiErrorResponseDataDetails,
2728
ISearchUserDirectoryResult,
2829
IGetMediaConfigResult,
2930
UpdateDelayedEventAction,
@@ -33,6 +34,7 @@ import {
3334
ITurnServer as IClientTurnServer,
3435
EventType,
3536
IContent,
37+
MatrixError,
3638
MatrixEvent,
3739
Room,
3840
Direction,
@@ -689,4 +691,15 @@ export class StopGapWidgetDriver extends WidgetDriver {
689691
const blob = await response.blob();
690692
return { file: blob };
691693
}
694+
695+
/**
696+
* Expresses a {@link MatrixError} as a JSON payload
697+
* for use by Widget API error responses.
698+
* @param error The error to handle.
699+
* @returns The error expressed as a JSON payload,
700+
* or undefined if it is not a {@link MatrixError}.
701+
*/
702+
public processError(error: unknown): IWidgetApiErrorResponseDataDetails | undefined {
703+
return error instanceof MatrixError ? { matrix_api_error: error.asWidgetApiErrorData() } : undefined;
704+
}
692705
}

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8309,7 +8309,7 @@ [email protected]:
83098309

83108310
"matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop":
83118311
version "34.10.0"
8312-
resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/5a1488ebd5552817b1e95265afe7b3baac1231a2"
8312+
resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/6855ace6422082d173438cb23368d2fabc6a1086"
83138313
dependencies:
83148314
"@babel/runtime" "^7.12.5"
83158315
"@matrix-org/matrix-sdk-crypto-wasm" "^9.0.0"
@@ -8320,7 +8320,7 @@ [email protected]:
83208320
jwt-decode "^4.0.0"
83218321
loglevel "^1.7.1"
83228322
matrix-events-sdk "0.0.1"
8323-
matrix-widget-api "^1.8.2"
8323+
matrix-widget-api "^1.10.0"
83248324
oidc-client-ts "^3.0.1"
83258325
p-retry "4"
83268326
sdp-transform "^2.14.1"
@@ -8345,10 +8345,10 @@ matrix-web-i18n@^3.2.1:
83458345
minimist "^1.2.8"
83468346
walk "^2.3.15"
83478347

8348-
matrix-widget-api@^1.8.2, matrix-widget-api@^1.9.0:
8349-
version "1.9.0"
8350-
resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.9.0.tgz#884136b405bd3c56e4ea285095c9e01ec52b6b1f"
8351-
integrity sha512-au8mqralNDqrEvaVAkU37bXOb8I9SCe+ACdPk11QWw58FKstVq31q2wRz+qWA6J+42KJ6s1DggWbG/S3fEs3jw==
8348+
matrix-widget-api@^1.10.0:
8349+
version "1.10.0"
8350+
resolved "https://registry.yarnpkg.com/matrix-widget-api/-/matrix-widget-api-1.10.0.tgz#d31ea073a5871a1fb1a511ef900b0c125a37bf55"
8351+
integrity sha512-rkAJ29briYV7TJnfBVLVSKtpeBrBju15JZFSDP6wj8YdbCu1bdmlplJayQ+vYaw1x4fzI49Q+Nz3E85s46sRDw==
83528352
dependencies:
83538353
"@types/events" "^3.0.0"
83548354
events "^3.2.0"

0 commit comments

Comments
 (0)