mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-13 18:03:10 -06:00
Improved error handling/reporting
This commit is contained in:
parent
c4d1af68b1
commit
86606e68eb
|
|
@ -76,7 +76,10 @@ func GetAvatarURL(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localpart := getLocalPart(userID)
|
localpart := getLocalPart(userID)
|
||||||
if profile, err := accountDB.GetProfileByLocalpart(localpart); err == nil {
|
profile, err := accountDB.GetProfileByLocalpart(localpart)
|
||||||
|
if err != nil {
|
||||||
|
return httputil.LogThenError(req, err)
|
||||||
|
}
|
||||||
res := avatarURL{
|
res := avatarURL{
|
||||||
AvatarURL: profile.AvatarURL,
|
AvatarURL: profile.AvatarURL,
|
||||||
}
|
}
|
||||||
|
|
@ -84,11 +87,6 @@ func GetAvatarURL(
|
||||||
Code: 200,
|
Code: 200,
|
||||||
JSON: res,
|
JSON: res,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: 500,
|
|
||||||
JSON: jsonerror.Unknown("Failed to load avatar URL"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAvatarURL implements PUT /profile/{userID}/avatar_url
|
// SetAvatarURL implements PUT /profile/{userID}/avatar_url
|
||||||
|
|
@ -125,7 +123,7 @@ func SetAvatarURL(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDisplayName implements GET /profile/{userID}/displayname
|
// GetDisplayName implements GET /profile/{userID}/displayname
|
||||||
func GetDisplayName(
|
func GetDisplayName(
|
||||||
req *http.Request, accountDB *accounts.Database, userID string,
|
req *http.Request, accountDB *accounts.Database, userID string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
|
|
@ -136,7 +134,10 @@ func GetDisplayName(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localpart := getLocalPart(userID)
|
localpart := getLocalPart(userID)
|
||||||
if profile, err := accountDB.GetProfileByLocalpart(localpart); err == nil {
|
profile, err := accountDB.GetProfileByLocalpart(localpart)
|
||||||
|
if err != nil {
|
||||||
|
return httputil.LogThenError(req, err)
|
||||||
|
}
|
||||||
res := displayName{
|
res := displayName{
|
||||||
DisplayName: profile.DisplayName,
|
DisplayName: profile.DisplayName,
|
||||||
}
|
}
|
||||||
|
|
@ -144,11 +145,6 @@ func GetDisplayName(
|
||||||
Code: 200,
|
Code: 200,
|
||||||
JSON: res,
|
JSON: res,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: 500,
|
|
||||||
JSON: jsonerror.Unknown("Failed to load display name"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDisplayName implements PUT /profile/{userID}/displayname
|
// SetDisplayName implements PUT /profile/{userID}/displayname
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue