|
| 1 | +using CSharpToJavaScript.Utils; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Linq; |
| 5 | +using System.Text; |
| 6 | +using System.Threading.Tasks; |
| 7 | +using static System.Runtime.InteropServices.JavaScript.JSType; |
| 8 | + |
| 9 | +namespace CSharpToJavaScript.APIs.JS.Ecma; |
| 10 | + |
| 11 | +//https://262.ecma-international.org/14.0/#sec-error-objects |
| 12 | + |
| 13 | +[To(ToAttribute.Default)] |
| 14 | +public class Error : ErrorPrototype |
| 15 | +{ |
| 16 | + [To(ToAttribute.FirstCharToLowerCase)] |
| 17 | + public static ErrorPrototype Prototype { get; } = new(); |
| 18 | + |
| 19 | + [To(ToAttribute.Default)] |
| 20 | + public Error(string message, object? options = null) |
| 21 | + { |
| 22 | + |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +[To(ToAttribute.FirstCharToLowerCase)] |
| 27 | +public class ErrorPrototype |
| 28 | +{ |
| 29 | + public string Message { get; set; } = string.Empty; |
| 30 | + public string Name { get; set; } = "Error"; |
| 31 | + public ErrorPrototype() { } |
| 32 | + public string ToString() |
| 33 | + { |
| 34 | + throw new NotImplementedException(); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +[To(ToAttribute.Default)] |
| 39 | +public class EvalError : Error |
| 40 | +{ |
| 41 | + [To(ToAttribute.Default)] |
| 42 | + public EvalError(string message) : base(message) { } |
| 43 | +} |
| 44 | + |
| 45 | +[To(ToAttribute.Default)] |
| 46 | +public class RangeError : Error |
| 47 | +{ |
| 48 | + [To(ToAttribute.Default)] |
| 49 | + public RangeError(string message) : base(message) { } |
| 50 | +} |
| 51 | + |
| 52 | +[To(ToAttribute.Default)] |
| 53 | +public class ReferenceError : Error |
| 54 | +{ |
| 55 | + [To(ToAttribute.Default)] |
| 56 | + public ReferenceError(string message) : base(message) { } |
| 57 | +} |
| 58 | + |
| 59 | +[To(ToAttribute.Default)] |
| 60 | +public class SyntaxError : Error |
| 61 | +{ |
| 62 | + [To(ToAttribute.Default)] |
| 63 | + public SyntaxError(string message) : base(message) { } |
| 64 | +} |
| 65 | + |
| 66 | +[To(ToAttribute.Default)] |
| 67 | +public class TypeError : Error |
| 68 | +{ |
| 69 | + [To(ToAttribute.Default)] |
| 70 | + public TypeError(string message) : base(message) { } |
| 71 | +} |
| 72 | + |
| 73 | +[To(ToAttribute.Default)] |
| 74 | +public class URIError : Error |
| 75 | +{ |
| 76 | + [To(ToAttribute.Default)] |
| 77 | + public URIError(string message) : base(message) { } |
| 78 | +} |
| 79 | + |
| 80 | +//TODO? |
| 81 | +//https://262.ecma-international.org/14.0/#sec-nativeerror-object-structure |
| 82 | + |
| 83 | +[To(ToAttribute.Default)] |
| 84 | +public class AggregateError : AggregateErrorPrototype |
| 85 | +{ |
| 86 | + [To(ToAttribute.FirstCharToLowerCase)] |
| 87 | + public static AggregateErrorPrototype Prototype { get; } = new(); |
| 88 | + |
| 89 | + [To(ToAttribute.Default)] |
| 90 | + public AggregateError(object[] errors, string message, object? options = null) |
| 91 | + { |
| 92 | + |
| 93 | + } |
| 94 | +} |
| 95 | +public class AggregateErrorPrototype |
| 96 | +{ |
| 97 | + public string Message { get; set; } = string.Empty; |
| 98 | + public string Name { get; set; } = "AggregateError"; |
| 99 | + public AggregateErrorPrototype() { } |
| 100 | +} |
0 commit comments