Skip to content

Commit

Permalink
chore(ci): handle workflow error
Browse files Browse the repository at this point in the history
  • Loading branch information
cherrynik committed Sep 27, 2023
1 parent 6036939 commit 5bc99e4
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Apps/GameDesktop/GameDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SpriteSheets.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\Errors.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Errors.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Entitas" Version="1.14.2" />
Expand Down Expand Up @@ -73,6 +77,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>SpriteSheets.resx</DependentUpon>
</Compile>
<Compile Update="Resources\Errors.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Errors.resx</DependentUpon>
</Compile>
</ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
Expand Down
9 changes: 9 additions & 0 deletions src/Apps/GameDesktop/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using System;
using GameDesktop;
using GameDesktop.Resources;
using LightInject;
using Microsoft.Extensions.Configuration;
using Serilog;
using Serilog.Core;

IConfigurationRoot configuration = ConfigurationFactory.Create();
bool IsCI = configuration.GetValue("IS_CI", "false") == "true";

using Logger logger = LogFactory.Create(configuration);

logger.ForContext<Program>().Verbose("Configuration & Logger (+ Sentry) initialized");
Expand All @@ -30,6 +33,12 @@
}
catch (Exception e)
{
if (e.Source.Contains(Errors.NoGraphicsDeviceSource) &&
e.Message.Contains(Errors.NoGraphicsDeviceMessage) && IsCI)
{
Environment.Exit(0);
}

logger.ForContext<Program>().Fatal(e.ToString());
Environment.Exit(1);
}
60 changes: 60 additions & 0 deletions src/Apps/GameDesktop/Resources/Errors.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/Apps/GameDesktop/Resources/Errors.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>

<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>

<data name="NoGraphicsDeviceSource">Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException</data>
<data name="NoGraphicsDeviceMessage">Failed to create graphics device!</data>
</root>

0 comments on commit 5bc99e4

Please sign in to comment.