diff --git a/lib/types.js b/lib/types.js index 5521296c..cba76fd2 100644 --- a/lib/types.js +++ b/lib/types.js @@ -202,14 +202,10 @@ class Type { if (!UnionType) { if (typeof opts.wrapUnions === 'function') { // we have a projection function - try { - projectionFn = opts.wrapUnions(types); - UnionType = typeof projectionFn !== 'undefined' - ? UnwrappedUnionType - : WrappedUnionType; - } catch(e) { - throw new Error(`Error generating projection function: ${e}`); - } + projectionFn = opts.wrapUnions(types); + UnionType = typeof projectionFn !== 'undefined' + ? UnwrappedUnionType + : WrappedUnionType; } else { UnionType = isAmbiguous(types) ? WrappedUnionType : UnwrappedUnionType; } @@ -1319,11 +1315,7 @@ class UnwrappedUnionType extends UnionType { super(schema, opts); if (!_projectionFn && opts && typeof opts.wrapUnions === 'function') { - try { - _projectionFn = opts.wrapUnions(this.types); - } catch(e) { - throw new Error(`Error generating projection function: ${e}`); - } + _projectionFn = opts.wrapUnions(this.types); } this._getIndex = _projectionFn ? generateProjectionIndexer(_projectionFn)