1+ using Jint . Collections ;
12using Jint . Native . Object ;
23using Jint . Runtime ;
34using Jint . Runtime . Descriptors ;
5+ using Jint . Runtime . Interop ;
46
57namespace Jint . Native . Error ;
68
@@ -25,14 +27,23 @@ internal ErrorConstructor(
2527
2628 internal ErrorPrototype PrototypeObject { get ; }
2729
30+ protected override void Initialize ( )
31+ {
32+ var properties = new PropertyDictionary ( 3 , checkExistingKeys : false )
33+ {
34+ [ "isError" ] = new PropertyDescriptor ( new PropertyDescriptor ( new ClrFunction ( Engine , "isError" , IsError , 1 ) , PropertyFlag . NonEnumerable ) ) ,
35+ } ;
36+ SetProperties ( properties ) ;
37+ }
38+
2839 protected internal override JsValue Call ( JsValue thisObject , JsValue [ ] arguments )
2940 {
3041 return Construct ( arguments , this ) ;
3142 }
3243
3344 public ObjectInstance Construct ( string ? message = null )
3445 {
35- return Construct ( message != null ? new JsValue [ ] { message } : System . Array . Empty < JsValue > ( ) , this ) ;
46+ return Construct ( message != null ? new JsValue [ ] { message } : System . Array . Empty < JsValue > ( ) , this ) ;
3647 }
3748
3849 /// <summary>
@@ -83,4 +94,12 @@ public override ObjectInstance Construct(JsValue[] arguments, JsValue newTarget)
8394 return callStack . BuildCallStackString ( _engine , lastSyntaxNode . Location , currentFunction == this ? 1 : 0 ) ;
8495 }
8596 }
97+
98+ /// <summary>
99+ /// https://tc39.es/proposal-is-error/
100+ /// </summary>
101+ private static JsValue IsError ( JsValue ? thisObj , JsValue [ ] arguments )
102+ {
103+ return arguments . At ( 0 ) is JsError ;
104+ }
86105}
0 commit comments