File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export class Value<T extends Type = Type> {
66 public type : T ,
77 public data : ResolveType < T > ,
88 ) { }
9-
9+
1010 public encode ( codec : JsonValueCodec ) : void {
1111 const value = this . data ;
1212 const type = this . type ;
@@ -16,3 +16,24 @@ export class Value<T extends Type = Type> {
1616 else type . encoder ( codec . format ) ( value , encoder ) ;
1717 }
1818}
19+
20+ if ( process . env . NODE_ENV !== 'production' ) {
21+ const encode = Value . prototype . encode ;
22+ Value . prototype . encode = function ( codec : JsonValueCodec ) : void {
23+ try {
24+ encode . call ( this , codec ) ;
25+ } catch ( error ) {
26+ try {
27+ // tslint:disable-next-line no-console
28+ console . error ( error ) ;
29+ const type = this . type ;
30+ if ( type ) {
31+ const err = type . validator ( 'object' ) ( this . data ) ;
32+ // tslint:disable-next-line no-console
33+ console . error ( err ) ;
34+ }
35+ } catch { }
36+ throw error ;
37+ }
38+ } ;
39+ }
You can’t perform that action at this time.
0 commit comments