This repository was archived by the owner on Apr 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathEcmaScriptThrow.cs
More file actions
63 lines (54 loc) · 1.97 KB
/
EcmaScriptThrow.cs
File metadata and controls
63 lines (54 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//------------------------------------------------------------------------------
// <license file="EcmaScriptThrow.cs">
//
// The use and distribution terms for this software are contained in the file
// named 'LICENSE', which can be found in the resources directory of this
// distribution.
//
// By using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
//
// </license>
//------------------------------------------------------------------------------
using System;
namespace EcmaScript.NET
{
/// <summary> Java reflection of JavaScript exceptions.
/// Instances of this class are thrown by the JavaScript 'throw' keyword.
///
/// </summary>
public class EcmaScriptThrow : EcmaScriptException
{
/// <returns> the value wrapped by this exception
/// </returns>
public virtual object Value
{
get
{
return value;
}
}
/// <summary>
/// Create a JavaScript exception wrapping the given JavaScript value
/// </summary>
/// <param name="value">the JavaScript value thrown.</param>
public EcmaScriptThrow (object value, string sourceName, int lineNumber)
{
RecordErrorOrigin (sourceName, lineNumber, null, 0);
this.value = value;
}
public override string Message
{
get
{
IScriptable scriptable = (value as IScriptable);
if (scriptable != null) {
// to prevent potential of evaluation and throwing more exceptions
return ScriptRuntime.DefaultObjectToString (scriptable);
}
return ScriptConvert.ToString (value);
}
}
private object value;
}
}