mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 19:33:09 -06:00
Return more useful error if room version query doesn't find the room
This commit is contained in:
parent
3c2811e705
commit
4981ad60d6
|
|
@ -18,6 +18,7 @@ package postgres
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/matrix-org/dendrite/common"
|
||||
|
|
@ -176,6 +177,9 @@ func (s *roomStatements) selectRoomVersionForRoomID(
|
|||
var roomVersion gomatrixserverlib.RoomVersion
|
||||
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomIDStmt)
|
||||
err := stmt.QueryRowContext(ctx, roomID).Scan(&roomVersion)
|
||||
if err == sql.ErrNoRows {
|
||||
return roomVersion, errors.New("room not found")
|
||||
}
|
||||
return roomVersion, err
|
||||
}
|
||||
|
||||
|
|
@ -185,5 +189,8 @@ func (s *roomStatements) selectRoomVersionForRoomNID(
|
|||
var roomVersion gomatrixserverlib.RoomVersion
|
||||
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomNIDStmt)
|
||||
err := stmt.QueryRowContext(ctx, roomNID).Scan(&roomVersion)
|
||||
if err == sql.ErrNoRows {
|
||||
return roomVersion, errors.New("room not found")
|
||||
}
|
||||
return roomVersion, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import (
|
|||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/matrix-org/dendrite/common"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
|
|
@ -168,6 +169,9 @@ func (s *roomStatements) selectRoomVersionForRoomID(
|
|||
var roomVersion gomatrixserverlib.RoomVersion
|
||||
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomIDStmt)
|
||||
err := stmt.QueryRowContext(ctx, roomID).Scan(&roomVersion)
|
||||
if err == sql.ErrNoRows {
|
||||
return roomVersion, errors.New("room not found")
|
||||
}
|
||||
return roomVersion, err
|
||||
}
|
||||
|
||||
|
|
@ -177,5 +181,8 @@ func (s *roomStatements) selectRoomVersionForRoomNID(
|
|||
var roomVersion gomatrixserverlib.RoomVersion
|
||||
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomNIDStmt)
|
||||
err := stmt.QueryRowContext(ctx, roomNID).Scan(&roomVersion)
|
||||
if err == sql.ErrNoRows {
|
||||
return roomVersion, errors.New("room not found")
|
||||
}
|
||||
return roomVersion, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue