1
+ using Jint . Collections ;
1
2
using Jint . Native . Object ;
2
3
using Jint . Runtime ;
3
4
using Jint . Runtime . Descriptors ;
5
+ using Jint . Runtime . Interop ;
4
6
5
7
namespace Jint . Native . Error ;
6
8
@@ -25,14 +27,23 @@ internal ErrorConstructor(
25
27
26
28
internal ErrorPrototype PrototypeObject { get ; }
27
29
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
+
28
39
protected internal override JsValue Call ( JsValue thisObject , JsValue [ ] arguments )
29
40
{
30
41
return Construct ( arguments , this ) ;
31
42
}
32
43
33
44
public ObjectInstance Construct ( string ? message = null )
34
45
{
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 ) ;
36
47
}
37
48
38
49
/// <summary>
@@ -83,4 +94,12 @@ public override ObjectInstance Construct(JsValue[] arguments, JsValue newTarget)
83
94
return callStack . BuildCallStackString ( _engine , lastSyntaxNode . Location , currentFunction == this ? 1 : 0 ) ;
84
95
}
85
96
}
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
+ }
86
105
}
0 commit comments