Propagate missing oject CIDs through MissingObject exception
This commit is contained in:
parent
c8e4cd783d
commit
6fd4756222
|
@ -571,6 +571,9 @@ proc eval(ast: Node; env: Env): Node =
|
|||
newNodeError(getCurrentExceptionMsg(), ast[])
|
||||
except FieldError:
|
||||
newNodeError("invalid argument", ast[])
|
||||
except MissingObject:
|
||||
let e = (MissingObject)getCurrentException()
|
||||
newNodeError($e.cid & " not in store", ast[])
|
||||
|
||||
proc main() =
|
||||
var
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
import asyncdispatch, asyncfile, streams, strutils, os, ipld, cbor, multiformats, hex, ropes
|
||||
|
||||
type
|
||||
MissingObject* = object of SystemError
|
||||
MissingObject* = ref object of SystemError
|
||||
cid*: Cid ## Missing object identifier
|
||||
|
||||
proc newMissingObject*(cid: Cid): MissingObject =
|
||||
MissingObject(msg: "object missing from store", cid: cid)
|
||||
|
||||
type
|
||||
IpldStore* = ref IpldStoreObj
|
||||
IpldStoreObj* = object of RootObj
|
||||
closeImpl*: proc (s: IpldStore) {.nimcall, gcsafe.}
|
||||
|
@ -112,7 +118,7 @@ proc fsGetRaw(s: IpldStore; cid: Cid): Future[string] =
|
|||
discard tryRemoveFile path
|
||||
# bad block, remove it
|
||||
if not result.finished:
|
||||
result.fail newException(MissingObject, $cid)
|
||||
result.fail cid.newMissingObject
|
||||
|
||||
proc fsPutDag(s: IpldStore; dag: Dag): Future[Cid] {.async.} =
|
||||
var fs = FileStore(s)
|
||||
|
|
Loading…
Reference in New Issue
Block a user