diff options
author | Fabio Berger <me@fabioberger.com> | 2017-05-25 18:08:21 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-05-25 18:08:21 +0800 |
commit | ae47981669e4c471623f22f8ecee93709dfe47bd (patch) | |
tree | 1fa721da73dec93708fd7125de08f308f54615a4 /src | |
parent | fa559377c80a75ba4169cab0825e5808154ae72b (diff) | |
download | dexon-0x-contracts-ae47981669e4c471623f22f8ecee93709dfe47bd.tar.gz dexon-0x-contracts-ae47981669e4c471623f22f8ecee93709dfe47bd.tar.zst dexon-0x-contracts-ae47981669e4c471623f22f8ecee93709dfe47bd.zip |
Pretty print passed in order and schema validation errors in thrown assertion
Diffstat (limited to 'src')
-rw-r--r-- | src/ts/utils/assert.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ts/utils/assert.ts b/src/ts/utils/assert.ts index 7fb51fbdc..972047118 100644 --- a/src/ts/utils/assert.ts +++ b/src/ts/utils/assert.ts @@ -22,8 +22,10 @@ export const assert = { const schemaValidator = new SchemaValidator(); const validationResult = schemaValidator.validate(value, schema); const hasValidationErrors = validationResult.errors.length > 0; - const assertMsg = `Expected ${variableName} to conform to schema ${schema.id}, encountered: $value`; - this.assert(!hasValidationErrors, assertMsg); + const msg = `Expected ${variableName} to conform to schema ${schema.id} +Encountered: ${JSON.stringify(value, null, '\t')} +Validation errors: ${validationResult.errors.join(', ')}`; + this.assert(!hasValidationErrors, msg); }, assert(condition: boolean, message: string) { if (!condition) { |