Skip to content

Commit eeedd88

Browse files
committed
try/catch rename to attempt/on_error
1 parent 2f27411 commit eeedd88

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

Code/ContextSystem/Contexts/Control/TryStatement.cs renamed to Code/ContextSystem/Contexts/Control/AttemptStatement.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99
namespace SER.Code.ContextSystem.Contexts.Control;
1010

1111
[UsedImplicitly]
12-
public class TryStatement : StatementContext, IExtendableStatement, IKeywordContext
12+
public class AttemptStatement : StatementContext, IExtendableStatement, IKeywordContext
1313
{
14-
public string KeywordName => "try";
14+
public string KeywordName => "attempt";
1515
public string Description => "Runs everything inside the statement, and if something throws an exception (error), " +
1616
"the statement skips everything after it and jumps straight to the " +
17-
$"{typeof(CatchStatement).FriendlyTypeName(true)} " +
17+
$"{typeof(OnErrorStatement).FriendlyTypeName(true)} " +
1818
"after it if provided.";
1919
public string[] Arguments => [];
2020
public string? Example =>
2121
"""
2222
&collection = EmptyCollection
2323
# swallows the error (doesn't stop the script)
24-
try
24+
attempt
2525
Print {CollectionFetch &collection 2}
2626
# throws because there's nothing at index 2
2727
end
2828
""";
2929

3030
public IExtendableStatement.Signal AllowedSignals => IExtendableStatement.Signal.ThrewException;
3131
public Dictionary<IExtendableStatement.Signal, StatementContext> RegisteredSignals { get; } = [];
32-
protected override string FriendlyName => "'try' statement";
32+
protected override string FriendlyName => "'attempt' statement";
3333

3434
private Exception? _exception;
3535

@@ -66,7 +66,7 @@ protected override IEnumerator<float> Execute()
6666
if (!RegisteredSignals.TryGetValue(IExtendableStatement.Signal.ThrewException, out var statement))
6767
yield break;
6868

69-
if (statement is CatchStatement catchStatement)
69+
if (statement is OnErrorStatement catchStatement)
7070
{
7171
catchStatement.Exception = _exception;
7272
}

Code/ContextSystem/Contexts/Control/CatchStatement.cs renamed to Code/ContextSystem/Contexts/Control/OnErrorStatement.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@
1313
namespace SER.Code.ContextSystem.Contexts.Control;
1414

1515
[UsedImplicitly]
16-
public class CatchStatement : StatementContext, IStatementExtender, IKeywordContext, IAcceptOptionalVariableDefinitionsContext
16+
public class OnErrorStatement : StatementContext, IStatementExtender, IKeywordContext, IAcceptOptionalVariableDefinitionsContext
1717
{
18-
public string KeywordName => "catch";
18+
public string KeywordName => "on_error";
1919
public string Description => "Catches an exception thrown inside of a " +
20-
typeof(TryStatement).FriendlyTypeName(true);
20+
typeof(AttemptStatement).FriendlyTypeName(true);
2121
public string[] Arguments => [];
2222
public string? Example =>
2323
"""
2424
&collection = EmptyCollection
25-
try
25+
attempt
2626
Print {CollectionFetch &collection 2}
2727
# throws because there's nothing at index 2
28-
catch
28+
on_error
2929
with *exception
3030
3131
Print "Error!: {ExceptionInfo *exception message}"
3232
end
3333
""";
3434

3535
public IExtendableStatement.Signal Extends => IExtendableStatement.Signal.ThrewException;
36-
protected override string FriendlyName => "'catch' statement";
36+
protected override string FriendlyName => "'on_error' statement";
3737

3838
public Exception? Exception
3939
{

0 commit comments

Comments
 (0)