From 43cddfe00f53e3a2df4769be31c66cd818a2966e Mon Sep 17 00:00:00 2001 From: Kegsay Date: Thu, 25 Jun 2020 15:04:48 +0100 Subject: 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 --- clientapi/jsonerror/jsonerror.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'clientapi/jsonerror/jsonerror.go') 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 -- cgit v1.2.3