convector icon indicating copy to clipboard operation
convector copied to clipboard

Ignored Errors from chaincode

Open walmon opened this issue 6 years ago • 0 comments

The problem

When an Error occurs inside of the chaincode (i.e.: making a throw new Error(...)) the returning message is not parsed as an Error object, therefore errors are going missing. It's returning null right now.

Environment

  • Convector version (or git revision) that exhibits the issue: 1.2.0
  • Last Convector version that did not exhibit the issue (if applicable):
  • OS/version: MAC Mojave 10.14
  • Node.js version: v8.12.0
  • Npm or Yarn package manager: 6.4.1
  • Convector CLI version (if applicable): 1.0.6
  • Hurley CLI version (if applicable):

Details

Unexpected way of handling errors, looks like Fabric changed something from 1.1 to 1.3-1.4.

Current Behavior

It returns null instead of an Error object.

Expected Behavior

Throw the original Error.

Code To Reproduce Issue [ Good To Have ]

Inside a controller

throw new Error(`Ups, the requesting identity is not authorized to update the model`);

In a unit test just call it with a try catch and the error won't be found, but the response will be null.

 try {
            let rs = await mybuggychaincodeCtrl.update(modelSample);
            // returns null
            console.log(rs);
            await expect.fail('Should have failed');
        } catch (ex) {
            // should fall in here
            console.log(ex);
        }

walmon avatar Feb 28 '19 17:02 walmon