Skip to content

Commit

Permalink
Let widget driver send error details (#28357)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AndrewFerr authored Nov 11, 2024
1 parent 17de661 commit c8c1074
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"matrix-encrypt-attachment": "^1.0.3",
"matrix-events-sdk": "0.0.1",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",
"matrix-widget-api": "^1.9.0",
"matrix-widget-api": "^1.10.0",
"memoize-one": "^6.0.0",
"oidc-client-ts": "^3.0.1",
"opus-recorder": "^8.0.3",
Expand Down
13 changes: 13 additions & 0 deletions src/stores/widgets/StopGapWidgetDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
WidgetDriver,
WidgetEventCapability,
WidgetKind,
IWidgetApiErrorResponseDataDetails,
ISearchUserDirectoryResult,
IGetMediaConfigResult,
UpdateDelayedEventAction,
Expand All @@ -33,6 +34,7 @@ import {
ITurnServer as IClientTurnServer,
EventType,
IContent,
MatrixError,
MatrixEvent,
Room,
Direction,
Expand Down Expand Up @@ -689,4 +691,15 @@ export class StopGapWidgetDriver extends WidgetDriver {
const blob = await response.blob();
return { file: blob };
}

/**
* Expresses a {@link MatrixError} as a JSON payload
* for use by Widget API error responses.
* @param error The error to handle.
* @returns The error expressed as a JSON payload,
* or undefined if it is not a {@link MatrixError}.
*/
public processError(error: unknown): IWidgetApiErrorResponseDataDetails | undefined {
return error instanceof MatrixError ? { matrix_api_error: error.asWidgetApiErrorData() } : undefined;
}
}
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8309,7 +8309,7 @@ matrix-events-sdk@0.0.1:

"matrix-js-sdk@github:matrix-org/matrix-js-sdk#develop":
version "34.10.0"
resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/5a1488ebd5552817b1e95265afe7b3baac1231a2"
resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/6855ace6422082d173438cb23368d2fabc6a1086"
dependencies:
"@babel/runtime" "^7.12.5"
"@matrix-org/matrix-sdk-crypto-wasm" "^9.0.0"
Expand All @@ -8320,7 +8320,7 @@ matrix-events-sdk@0.0.1:
jwt-decode "^4.0.0"
loglevel "^1.7.1"
matrix-events-sdk "0.0.1"
matrix-widget-api "^1.8.2"
matrix-widget-api "^1.10.0"
oidc-client-ts "^3.0.1"
p-retry "4"
sdp-transform "^2.14.1"
Expand All @@ -8345,10 +8345,10 @@ matrix-web-i18n@^3.2.1:
minimist "^1.2.8"
walk "^2.3.15"

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

0 comments on commit c8c1074

Please sign in to comment.