More verbose debugging

This commit is contained in:
Neil Alexander 2020-04-17 17:20:29 +01:00
parent b448c91b72
commit 6fb7b203dc

View file

@ -18,7 +18,8 @@ package postgres
import ( import (
"context" "context"
"database/sql" "database/sql"
"errors" "fmt"
"runtime/debug"
"github.com/lib/pq" "github.com/lib/pq"
"github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common"
@ -178,7 +179,8 @@ func (s *roomStatements) selectRoomVersionForRoomID(
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomIDStmt) stmt := common.TxStmt(txn, s.selectRoomVersionForRoomIDStmt)
err := stmt.QueryRowContext(ctx, roomID).Scan(&roomVersion) err := stmt.QueryRowContext(ctx, roomID).Scan(&roomVersion)
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
return roomVersion, errors.New("room not found") debug.PrintStack()
return roomVersion, fmt.Errorf("room ID %q not found", roomID)
} }
return roomVersion, err return roomVersion, err
} }
@ -190,7 +192,8 @@ func (s *roomStatements) selectRoomVersionForRoomNID(
stmt := common.TxStmt(txn, s.selectRoomVersionForRoomNIDStmt) stmt := common.TxStmt(txn, s.selectRoomVersionForRoomNIDStmt)
err := stmt.QueryRowContext(ctx, roomNID).Scan(&roomVersion) err := stmt.QueryRowContext(ctx, roomNID).Scan(&roomVersion)
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
return roomVersion, errors.New("room not found") debug.PrintStack()
return roomVersion, fmt.Errorf("room NID %d not found", roomNID)
} }
return roomVersion, err return roomVersion, err
} }