debug: Print more information about failing validations

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-02-25 10:55:03 +00:00 committed by Giovanni Garufi
parent f9626a3ee4
commit 987de0e097

View File

@ -4,6 +4,7 @@ import { Transaction } from 'knex';
import * as _ from 'lodash';
import { generateUniqueKey } from 'resin-register-device';
import StrictEventEmitter from 'strict-event-emitter-types';
import { inspect } from 'util';
import { Either } from 'fp-ts/lib/Either';
import * as t from 'io-ts';
@ -279,9 +280,10 @@ export class Config extends (EventEmitter as {
const decoded = type.decode(value);
if (decoded.isLeft()) {
throw new TypeError(
`Cannot set value for ${key}, as value failed validation: ${
decoded.value
}`,
`Cannot set value for ${key}, as value failed validation: ${inspect(
value,
{ depth: Infinity },
)}`,
);
}
return decoded.value;