|
9 | 9 | namespace SER.Code.ContextSystem.Contexts.Control; |
10 | 10 |
|
11 | 11 | [UsedImplicitly] |
12 | | -public class TryStatement : StatementContext, IExtendableStatement, IKeywordContext |
| 12 | +public class AttemptStatement : StatementContext, IExtendableStatement, IKeywordContext |
13 | 13 | { |
14 | | - public string KeywordName => "try"; |
| 14 | + public string KeywordName => "attempt"; |
15 | 15 | public string Description => "Runs everything inside the statement, and if something throws an exception (error), " + |
16 | 16 | "the statement skips everything after it and jumps straight to the " + |
17 | | - $"{typeof(CatchStatement).FriendlyTypeName(true)} " + |
| 17 | + $"{typeof(OnErrorStatement).FriendlyTypeName(true)} " + |
18 | 18 | "after it if provided."; |
19 | 19 | public string[] Arguments => []; |
20 | 20 | public string? Example => |
21 | 21 | """ |
22 | 22 | &collection = EmptyCollection |
23 | 23 | # swallows the error (doesn't stop the script) |
24 | | - try |
| 24 | + attempt |
25 | 25 | Print {CollectionFetch &collection 2} |
26 | 26 | # throws because there's nothing at index 2 |
27 | 27 | end |
28 | 28 | """; |
29 | 29 |
|
30 | 30 | public IExtendableStatement.Signal AllowedSignals => IExtendableStatement.Signal.ThrewException; |
31 | 31 | public Dictionary<IExtendableStatement.Signal, StatementContext> RegisteredSignals { get; } = []; |
32 | | - protected override string FriendlyName => "'try' statement"; |
| 32 | + protected override string FriendlyName => "'attempt' statement"; |
33 | 33 |
|
34 | 34 | private Exception? _exception; |
35 | 35 |
|
@@ -66,7 +66,7 @@ protected override IEnumerator<float> Execute() |
66 | 66 | if (!RegisteredSignals.TryGetValue(IExtendableStatement.Signal.ThrewException, out var statement)) |
67 | 67 | yield break; |
68 | 68 |
|
69 | | - if (statement is CatchStatement catchStatement) |
| 69 | + if (statement is OnErrorStatement catchStatement) |
70 | 70 | { |
71 | 71 | catchStatement.Exception = _exception; |
72 | 72 | } |
|
0 commit comments