Skip to content

Commit 36e5bb2

Browse files
committed
change missing credential error from 500 to 404
1 parent 5c1a6fe commit 36e5bb2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

server/datamodel.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,16 @@ func ErrUserNotFound(id, topic string, ts time.Time) *ServerComMessage {
648648
Timestamp: ts}}
649649
}
650650

651+
// ErrNotFound is an error for missing objects other than user or topic.
652+
func ErrNotFound(id, topic string, ts time.Time) *ServerComMessage {
653+
return &ServerComMessage{Ctrl: &MsgServerCtrl{
654+
Id: id,
655+
Code: http.StatusNotFound, // 404
656+
Text: "not found",
657+
Topic: topic,
658+
Timestamp: ts}}
659+
}
660+
651661
// ErrOperationNotAllowed a valid operation is not permitted in this context.
652662
func ErrOperationNotAllowed(id, topic string, ts time.Time) *ServerComMessage {
653663
return &ServerComMessage{Ctrl: &MsgServerCtrl{

server/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ func decodeStoreError(err error, id string, timestamp time.Time) *ServerComMessa
223223
errmsg = ErrPolicy(id, "", timestamp)
224224
case types.ErrCredentials:
225225
errmsg = InfoValidateCredentials(id, timestamp)
226+
case types.ErrNotFound:
227+
errmsg = ErrNotFound(id, "", timestamp)
226228
default:
227229
errmsg = ErrUnknown(id, "", timestamp)
228230
}

0 commit comments

Comments
 (0)