Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip ci] Miscellaneous scripting QoL improvements and fixes #2740

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: true
if: ${{ !contains(github.event.head_commit.message, 'skip')}}
if: ${{ !contains(github.event.head_commit.message, 'skip') || !contains(github.event.head_commit.message, 'skipci')}}
steps:
- name: dummy action
run: "echo 'dummy action that checks if the build is to be skipped, if it is, this action does not run to break the entire build action'"
4 changes: 2 additions & 2 deletions MinecraftClient/CommandHandler/CmdResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum Status
public CmdResult()
{
this.status = Status.NotRun;
this.result = null;
this.result = "Command did not run, cannot determine the result of the command.";
}

public Status status;
Expand All @@ -35,7 +35,7 @@ public int SetAndReturn(Status status)
this.result = status switch
{
#pragma warning disable format // @formatter:off
Status.NotRun => null,
Status.NotRun => "Command did not run, cannot determine the result of the command.",
Status.FailChunkNotLoad => null,
Status.FailNeedEntity => Translations.extra_entity_required,
Status.FailNeedInventory => Translations.extra_inventory_required,
Expand Down
12 changes: 8 additions & 4 deletions MinecraftClient/Scripting/CSharpRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,15 @@ class CSharpRunner

foreach (var failure in result.Failures)
{
ConsoleIO.WriteLogLine($"[Script] Error in {scriptName}, line:col{failure.Location.GetMappedLineSpan()}: [{failure.Id}] {failure.GetMessage()}");
// Get the line that contains the error:

var loc = failure.Location.GetMappedLineSpan();
var line = code.Split('\n')[loc.StartLinePosition.Line];

ConsoleIO.WriteLogLine($"[Script] Error in {scriptName}, on line ({line.Trim()}): [{failure.Id}] {failure.GetMessage()}");
}

throw new CSharpException(CSErrorType.InvalidScript, new InvalidProgramException("Compilation failed due to error."));
throw new CSharpException(CSErrorType.InvalidScript, new InvalidProgramException("Compilation failed due to error(s)."));
}

ConsoleIO.WriteLogLine("[Script] Compilation done with no errors.");
Expand Down Expand Up @@ -182,8 +187,7 @@ public class CSharpException : Exception
public CSErrorType ExceptionType { get { return _type; } }
public override string Message { get { return InnerException!.Message; } }
public override string ToString() { return InnerException!.ToString(); }
public CSharpException(CSErrorType type, Exception inner)
: base(inner != null ? inner.Message : "", inner)
public CSharpException(CSErrorType type, Exception inner) : base(inner.Message, inner)
{
_type = type;
}
Expand Down