bodhiproject/qrypto

When throwing errors, throw entire error object (not just the message/string)

Closed this issue · 1 comments

After testing with qweb3 the error passed back from rawCall, it seems that the error caught in the try/catch is not a proper Error instance, but just a string:

try {
      const result = await this.provider.rawCall('sendtocontract', [
        this.address,
        data,
        amt,
        limit,
        price.toFixed(8),
        senderAddress,
      ]);
    } catch (err) {
      throw Error(err.message || err);
    }

The err caught from this call const result = await this.provider.rawCall('sendtocontract', [ is returning as a string, but it should be returning an Error object (https://nodejs.org/api/errors.html#errors_class_error).

I have verified this by logging err.message from the rawCall and it is undefined. Make sure the errors being thrown from Qrypto are of Error types.

resolved PR193