didcomm-rust icon indicating copy to clipboard operation
didcomm-rust copied to clipboard

Swift wrapper, DidResolver not able to accept error callback with error kind, rust panic

Open ivanpagac opened this issue 2 years ago • 0 comments

As a user I would like to be able to know why resolution of did document failed, e.g. network error or simply not found. The API is available such as

public protocol DidResolver: AnyObject {
    func resolve(did: String, cb: OnDidResolverResult) -> ErrorCode
}

but when trying to invoke

try cb.error(err: .InvalidState(message: did), msg: "NetworkError")

then nor ErrorKind or msg is propagated to pack or unpack methods on error closure.

public func unpack(msg: String, options: UnpackOptions, cb: OnUnpackResult) -> ErrorCode
public protocol OnUnpackResult: AnyObject {
    func success(result: Message, metadata: UnpackMetadata)
    func error(err: ErrorKind, msg: String)
}

In the above err is always

(lldb) po error
▿ ErrorKind
  ▿ InvalidState : 1 element
    - message : "Invalid state"

and msg is always

(lldb) po msg
"Invalid state: Unable resolve signer did: can not resolve DID Doc: Invalid state: unable receive callback result: oneshot canceled: unable receive callback result: oneshot canceled"

What I would expect is ErrorKind is correctly propagated.

ivanpagac avatar Jan 10 '23 07:01 ivanpagac