diff options
author | Kegsay <kegan@matrix.org> | 2020-06-25 15:04:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 15:04:48 +0100 |
commit | 43cddfe00f53e3a2df4769be31c66cd818a2966e (patch) | |
tree | d7947effce9b38e94f04fce7adda71d0195c021f /clientapi | |
parent | c2d34422d65e81eee6e9d0c31a4c5a446fa9678a (diff) |
Return remote errors from FS.PerformJoin (#1164)
* Return remote errors from FS.PerformJoin
Follows the same pattern as PerformJoin on roomserver (no error return).
Also return the right format for incompatible room version errors.
Makes a bunch of tests pass!
* Handle network errors better when returning remote HTTP errors
* Linting
* Fix tests
* Update whitelist, pass network errors through in API=1 mode
Diffstat (limited to 'clientapi')
-rw-r--r-- | clientapi/jsonerror/jsonerror.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clientapi/jsonerror/jsonerror.go b/clientapi/jsonerror/jsonerror.go index 85e887ae..7f8f264b 100644 --- a/clientapi/jsonerror/jsonerror.go +++ b/clientapi/jsonerror/jsonerror.go @@ -125,10 +125,20 @@ func GuestAccessForbidden(msg string) *MatrixError { return &MatrixError{"M_GUEST_ACCESS_FORBIDDEN", msg} } +type IncompatibleRoomVersionError struct { + RoomVersion string `json:"room_version"` + Error string `json:"error"` + Code string `json:"errcode"` +} + // IncompatibleRoomVersion is an error which is returned when the client // requests a room with a version that is unsupported. -func IncompatibleRoomVersion(roomVersion gomatrixserverlib.RoomVersion) *MatrixError { - return &MatrixError{"M_INCOMPATIBLE_ROOM_VERSION", string(roomVersion)} +func IncompatibleRoomVersion(roomVersion gomatrixserverlib.RoomVersion) *IncompatibleRoomVersionError { + return &IncompatibleRoomVersionError{ + Code: "M_INCOMPATIBLE_ROOM_VERSION", + RoomVersion: string(roomVersion), + Error: "Your homeserver does not support the features required to join this room", + } } // UnsupportedRoomVersion is an error which is returned when the client |