Skip to content

Commit 46035af

Browse files
authored
agent: add context to SEMsgNotFound error (#1604)
1 parent 4b7fc34 commit 46035af

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Simplex/Messaging/Agent/Store.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ data StoreError
672672
| -- | Invitation not found
673673
SEInvitationNotFound String InvitationId
674674
| -- | Message not found
675-
SEMsgNotFound
675+
SEMsgNotFound String
676676
| -- | Command not found
677677
SECmdNotFound
678678
| -- | Currently not used. The intention was to pass current expected queue status in methods,

src/Simplex/Messaging/Agent/Store/AgentStore.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ createSndMsgDelivery db connId SndQueue {dbQueueId} msgId =
891891

892892
getSndMsgViaRcpt :: DB.Connection -> ConnId -> InternalSndId -> IO (Either StoreError SndMsg)
893893
getSndMsgViaRcpt db connId sndMsgId =
894-
firstRow toSndMsg SEMsgNotFound $
894+
firstRow toSndMsg (SEMsgNotFound "getSndMsgViaRcpt") $
895895
DB.query
896896
db
897897
[sql|
@@ -1027,15 +1027,15 @@ getExpiredSndMessages db connId SndQueue {dbQueueId} expireTs = do
10271027
setMsgUserAck :: DB.Connection -> ConnId -> InternalId -> IO (Either StoreError (RcvQueue, SMP.MsgId))
10281028
setMsgUserAck db connId agentMsgId = runExceptT $ do
10291029
(dbRcvId, srvMsgId) <-
1030-
ExceptT . firstRow id SEMsgNotFound $
1030+
ExceptT . firstRow id (SEMsgNotFound "setMsgUserAck") $
10311031
DB.query db "SELECT rcv_queue_id, broker_id FROM rcv_messages WHERE conn_id = ? AND internal_id = ?" (connId, agentMsgId)
10321032
rq <- ExceptT $ getRcvQueueById db connId dbRcvId
10331033
liftIO $ DB.execute db "UPDATE rcv_messages SET user_ack = ? WHERE conn_id = ? AND internal_id = ?" (BI True, connId, agentMsgId)
10341034
pure (rq, srvMsgId)
10351035

10361036
getRcvMsg :: DB.Connection -> ConnId -> InternalId -> IO (Either StoreError RcvMsg)
10371037
getRcvMsg db connId agentMsgId =
1038-
firstRow toRcvMsg SEMsgNotFound $
1038+
firstRow toRcvMsg (SEMsgNotFound "getRcvMsg") $
10391039
DB.query
10401040
db
10411041
[sql|
@@ -1085,7 +1085,7 @@ checkRcvMsgHashExists db connId hash = do
10851085

10861086
getRcvMsgBrokerTs :: DB.Connection -> ConnId -> SMP.MsgId -> IO (Either StoreError BrokerTs)
10871087
getRcvMsgBrokerTs db connId msgId =
1088-
firstRow fromOnly SEMsgNotFound $
1088+
firstRow fromOnly (SEMsgNotFound "getRcvMsgBrokerTs") $
10891089
DB.query db "SELECT broker_ts FROM rcv_messages WHERE conn_id = ? AND broker_id = ?" (connId, Binary msgId)
10901090

10911091
deleteMsg :: DB.Connection -> ConnId -> InternalId -> IO ()

0 commit comments

Comments
 (0)