mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-02-27 00:43:34 +00:00
checked exceptions in stores
This commit is contained in:
parent
414906a070
commit
5abce8107c
@ -161,7 +161,7 @@ proc retrieveCid(
|
||||
|
||||
proc retrieveInfoHash(
|
||||
node: CodexNodeRef, infoHash: MultiHash, resp: HttpResponseRef
|
||||
): Future[void] {.async.} =
|
||||
): Future[void] {.async: (raises: [CancelledError, HttpWriteError]).} =
|
||||
## Download torrent from the node in a streaming
|
||||
## manner
|
||||
##
|
||||
@ -194,13 +194,13 @@ proc retrieveInfoHash(
|
||||
|
||||
await resp.prepare(HttpResponseStreamType.Plain)
|
||||
|
||||
without torrentDownloader =?
|
||||
node.getTorrentDownloader(torrentManifest, codexManifest), err:
|
||||
without downloader =? node.getTorrentDownloader(torrentManifest, codexManifest), err:
|
||||
error "Unable to stream torrent", err = err.msg
|
||||
resp.status = Http500
|
||||
await resp.sendBody(err.msg)
|
||||
return
|
||||
|
||||
torrentDownloader = downloader
|
||||
torrentDownloader.start()
|
||||
|
||||
while not torrentDownloader.finished:
|
||||
@ -219,11 +219,6 @@ proc retrieveInfoHash(
|
||||
except CancelledError as exc:
|
||||
info "Stream cancelled", exc = exc.msg
|
||||
raise exc
|
||||
except CatchableError as exc:
|
||||
warn "Error streaming blocks", exc = exc.msg
|
||||
resp.status = Http500
|
||||
if resp.isPending():
|
||||
await resp.sendBody(exc.msg)
|
||||
finally:
|
||||
info "Sent bytes for torrent", infoHash = $infoHash, bytes
|
||||
await torrentDownloader.stop()
|
||||
|
||||
@ -157,6 +157,9 @@ method listBlocks*(
|
||||
without cid =? cid, err:
|
||||
trace "Cannot get Cid from the iterator", err = err.msg
|
||||
return false
|
||||
without isTorrent =? cid.isTorrentInfoHash, err:
|
||||
trace "Error checking if cid is a torrent info hash", err = err.msg
|
||||
return false
|
||||
without isManifest =? cid.isManifest, err:
|
||||
trace "Error checking if cid is a manifest", err = err.msg
|
||||
return false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user