summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-12-10 23:27:10 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-12-10 23:27:10 -0500
commit6bdd49af13ed6bdfef8220c85ca32bca904d3a1e (patch)
tree7ecb228b5a0e4ab2a617c09a9964ccc0e8d71086 /src/SMAPI
parent8776d1afa6dce054f3bc7cb421c86f3e2fe06ab3 (diff)
downloadSMAPI-6bdd49af13ed6bdfef8220c85ca32bca904d3a1e.tar.gz
SMAPI-6bdd49af13ed6bdfef8220c85ca32bca904d3a1e.tar.bz2
SMAPI-6bdd49af13ed6bdfef8220c85ca32bca904d3a1e.zip
detect libgdiplus-missing exception and show a friendly error instead (#408)
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/InternalExtensions.cs9
-rw-r--r--src/SMAPI/Framework/SContentManager.cs4
2 files changed, 12 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/InternalExtensions.cs b/src/SMAPI/Framework/InternalExtensions.cs
index f81e05a9..bec6c183 100644
--- a/src/SMAPI/Framework/InternalExtensions.cs
+++ b/src/SMAPI/Framework/InternalExtensions.cs
@@ -108,6 +108,15 @@ namespace StardewModdingAPI.Framework
}
}
+ /// <summary>Get the lowest exception in an exception stack.</summary>
+ /// <param name="exception">The exception from which to search.</param>
+ public static Exception GetInnermostException(this Exception exception)
+ {
+ while (exception.InnerException != null)
+ exception = exception.InnerException;
+ return exception;
+ }
+
/****
** Sprite batch
****/
diff --git a/src/SMAPI/Framework/SContentManager.cs b/src/SMAPI/Framework/SContentManager.cs
index 1803098d..ebea6c84 100644
--- a/src/SMAPI/Framework/SContentManager.cs
+++ b/src/SMAPI/Framework/SContentManager.cs
@@ -205,7 +205,7 @@ namespace StardewModdingAPI.Framework
return this.LoadImpl<T>(assetName, instance);
// load mod content
- SContentLoadException GetContentError(string reasonPhrase) => new SContentLoadException($"Failed loading content asset '{assetName}': {reasonPhrase}.");
+ SContentLoadException GetContentError(string reasonPhrase) => new SContentLoadException($"Failed loading content asset '{assetName}': {reasonPhrase}");
try
{
return this.WithWriteLock(() =>
@@ -252,6 +252,8 @@ namespace StardewModdingAPI.Framework
}
catch (Exception ex) when (!(ex is SContentLoadException))
{
+ if (ex.GetInnermostException() is DllNotFoundException dllEx && dllEx.Message == "libgdiplus.dylib")
+ throw GetContentError("couldn't find libgdiplus, which is needed to load mod images. Make sure Mono is installed and you're running the game through the normal launcher.");
throw new SContentLoadException($"The content manager failed loading content asset '{assetName}'.", ex);
}
}