Skip to content

Commit

Permalink
fix: extension loading
Browse files Browse the repository at this point in the history
we're bumping minor because the issues are in the vscode extension and we have to check if it works
  • Loading branch information
andrewmd5 committed Feb 10, 2024
1 parent 3908018 commit 1bc1f15
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 36 deletions.
5 changes: 2 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
VERSION="3.0.1-beta.1"
VERSION="3.0.2-beta.1"
MAJOR=3
MINOR=0
PATCH=1

PATCH=2
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@ jobs:
working-directory: ${{env.RUST_RUNTIME_ROOT}}

- name: Publish NodeJS Tools
run: npm publish "./bebop-tools-npm-${{ steps.dotenv.outputs.version }}/bebop-tools-v${{ steps.dotenv.outputs.version }}.tgz" --access public
run: npm publish "./bebop-tools-npm-${{ steps.dotenv.outputs.version }}/bebop-tools-v${{ steps.dotenv.outputs.version }}.tgz" --access public ${{ github.ref == 'refs/heads/vnext' && '--tag next' || '' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

- name: Publish TypeScript Runtime
run: npm publish "./bebop-runtime-ts-${{ steps.dotenv.outputs.version }}/bebop-v${{ steps.dotenv.outputs.version }}.tgz" --access public
run: npm publish "./bebop-runtime-ts-${{ steps.dotenv.outputs.version }}/bebop-v${{ steps.dotenv.outputs.version }}.tgz" --access public ${{ github.ref == 'refs/heads/vnext' && '--tag next' || '' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

Expand Down Expand Up @@ -449,7 +449,7 @@ jobs:
tag_name: ${{ github.ref }}
release_name: Bebop ${{ github.ref }}
draft: false
prerelease: false
prerelease: ${{ github.ref == 'refs/heads/vnext' }}

- name: Upload Compiler for Windows x64
uses: actions/upload-release-asset@v1
Expand Down
17 changes: 15 additions & 2 deletions Core/CompilerHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Core.Logging;
using Core.Meta;
using Core.Meta.Decorators;
using Spectre.Console;

namespace Core;

Expand Down Expand Up @@ -127,8 +128,20 @@ public CompilerHostBuilder WithExtensions(Dictionary<string, string> extensions)
_extensionRuntime = new ExtensionRuntime(DotEnv.Generated.Environment.Version, DiagnosticLogger.Instance.Out, DiagnosticLogger.Instance.Error);
foreach (var kv in extensions)
{
var extension = _extensionRuntime.LoadExtension(kv.Key, kv.Value);

Extension? extension;
try
{
extension = _extensionRuntime.LoadExtension(kv.Key, kv.Value);
}
catch (Exception e) when (e is ExtensionRuntimeException)
{
throw new CompilerException("Extension runtime encountered a fatal exception", e);
}
catch (Exception e) when (e is ExtensionException)
{
DiagnosticLogger.Instance.Error.MarkupInterpolated($"[maroon]Error loading extension {kv.Key}@{kv.Value}: {e.Message}[/]");
continue;
}
if (extension.Decorators is { Count: > 0 })
{
foreach (var decorator in extension.Decorators)
Expand Down
66 changes: 39 additions & 27 deletions Core/Logging/DiagnosticLogger.Enhanced.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,43 +55,55 @@ public void WriteTable(Table table)

private void RenderEnhancedException(Exception ex, int errorCode)
{
string code = Markup.Escape($"[BOP{errorCode}]");
try
{
string code = Markup.Escape($"[BOP{errorCode}]");

// Write error code and exception name
_err.Markup($"[red bold]Error {code}:[/] ");
_err.MarkupLine($"[white]{ex.Message}[/]");
// Write error code and exception name
_err.Markup($"[maroon]Error {code}:[/] ");
_err.MarkupLine($"[white]{ex.Message}[/]");

// Write file path if FileNotFoundException
if (ex is FileNotFoundException fileNotFoundException)
{
var filePath = new TextPath(fileNotFoundException?.FileName ?? "[unknown]")
{
StemStyle = Style.Parse("white"),
LeafStyle = Style.Parse("white")
};
_err.WriteLine();
_err.Write("File: ");
_err.Write(filePath);
_err.WriteLine();
}
if (ex is { StackTrace: null } and { InnerException: not null })
{
_err.WriteLine();
_err.MarkupLine("[red bold]Inner Exception:[/]");
if (_traceEnabled)
// Write file path if FileNotFoundException
if (ex is FileNotFoundException fileNotFoundException)
{
_err.WriteException(ex.InnerException);
var filePath = new TextPath(fileNotFoundException?.FileName ?? "[unknown]")
{
StemStyle = Style.Parse("white"),
LeafStyle = Style.Parse("white")
};
_err.WriteLine();
_err.Write("File: ");
_err.Write(filePath);
_err.WriteLine();
}
else
if (ex is { StackTrace: null } and { InnerException: not null })
{
_err.MarkupLine($"[white]{ex.InnerException.Message}[/]");
_err.WriteLine();
_err.MarkupLine("[maroon]Inner Exception:[/]");
if (_traceEnabled)
{
_err.WriteException(ex.InnerException);
}
else
{
_err.MarkupLine($"[white]{ex.InnerException.Message}[/]");

}
}
if (_traceEnabled && !string.IsNullOrWhiteSpace(ex.StackTrace))
{
// Write exception message
_err.WriteException(ex);
}
}
if (_traceEnabled && !string.IsNullOrWhiteSpace(ex.StackTrace))
catch (Exception e)
{
// Write exception message
_err.WriteLine($"{errorCode}:");
_err.WriteException(ex);
_err.WriteLine();
_err.WriteLine("An error occurred while rendering the exception:");
_err.WriteException(e);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal static SemVersionRange ValidateVersionRange(string? version)
throw new JsonException(message, new FormatException("Version range cannot be empty."));
if (version.Equals("*", StringComparison.OrdinalIgnoreCase))
throw new JsonException(message, new FormatException("Version range cannot be *."));
if (!Semver.SemVersionRange.TryParseNpm(version, out var v))
if (!Semver.SemVersionRange.TryParseNpm(version, true, out var v))
throw new JsonException(message, new FormatException("Version range is not in the correct SemVer/npm format."));
return v;
}
Expand Down

0 comments on commit 1bc1f15

Please sign in to comment.