diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-11 17:12:58 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-11 17:12:58 -0400 |
commit | e14916f9622592a993fad54fe184a03de0b95c7b (patch) | |
tree | e5b39d6b3dbcc837e933f16823697305e9f7fbec /src/SMAPI/Framework/Exceptions | |
parent | 8c8ec6a4572fd3e59b738fc7545fcddc764f4519 (diff) | |
download | SMAPI-e14916f9622592a993fad54fe184a03de0b95c7b.tar.gz SMAPI-e14916f9622592a993fad54fe184a03de0b95c7b.tar.bz2 SMAPI-e14916f9622592a993fad54fe184a03de0b95c7b.zip |
add error code to SContentLoadException
Diffstat (limited to 'src/SMAPI/Framework/Exceptions')
-rw-r--r-- | src/SMAPI/Framework/Exceptions/ContentLoadErrorType.cs | 21 | ||||
-rw-r--r-- | src/SMAPI/Framework/Exceptions/SContentLoadException.cs | 15 |
2 files changed, 34 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/Exceptions/ContentLoadErrorType.cs b/src/SMAPI/Framework/Exceptions/ContentLoadErrorType.cs new file mode 100644 index 00000000..16689b67 --- /dev/null +++ b/src/SMAPI/Framework/Exceptions/ContentLoadErrorType.cs @@ -0,0 +1,21 @@ +namespace StardewModdingAPI.Framework.Exceptions +{ + /// <summary>Indicates why loading an asset through the content pipeline failed.</summary> + internal enum ContentLoadErrorType + { + /// <summary>The asset name is empty or has an invalid format.</summary> + InvalidName, + + /// <summary>The asset doesn't exist.</summary> + AssetDoesNotExist, + + /// <summary>The asset is not available in the current context (e.g. an attempt to load another mod's assets).</summary> + AccessDenied, + + /// <summary>The asset exists, but the data could not be deserialized or it doesn't match the expected type.</summary> + InvalidData, + + /// <summary>An unknown error occurred.</summary> + Other + } +} diff --git a/src/SMAPI/Framework/Exceptions/SContentLoadException.cs b/src/SMAPI/Framework/Exceptions/SContentLoadException.cs index be1fe748..4db24d06 100644 --- a/src/SMAPI/Framework/Exceptions/SContentLoadException.cs +++ b/src/SMAPI/Framework/Exceptions/SContentLoadException.cs @@ -7,12 +7,23 @@ namespace StardewModdingAPI.Framework.Exceptions internal class SContentLoadException : ContentLoadException { /********* + ** Accessors + *********/ + /// <summary>Why loading the asset through the content pipeline failed.</summary> + public ContentLoadErrorType ErrorType { get; } + + + /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> + /// <param name="errorType">Why loading the asset through the content pipeline failed.</param> /// <param name="message">The error message.</param> /// <param name="ex">The underlying exception, if any.</param> - public SContentLoadException(string message, Exception? ex = null) - : base(message, ex) { } + public SContentLoadException(ContentLoadErrorType errorType, string message, Exception? ex = null) + : base(message, ex) + { + this.ErrorType = errorType; + } } } |