diff --git a/Achievments/AchievmentException.cs b/Achievments/AchievmentException.cs
new file mode 100644
index 0000000..3ae6dea
--- /dev/null
+++ b/Achievments/AchievmentException.cs
@@ -0,0 +1,44 @@
+using JetBrains.Annotations;
+using System;
+
+namespace NEG.Utils.Achievments
+{
+ public class AchievmentException : ApplicationException
+ {
+ ///
+ /// Id of related achievment
+ ///
+ ///
+ ///
+ public string Id { get; private set; }
+
+ public AchievmentException(string message, string achievmentId) : base(message)
+ {
+ Id = achievmentId;
+ }
+ }
+
+ public class AchievmentTypeExcetion : AchievmentException
+ {
+ ///
+ /// Expected achievment type under
+ ///
+ ///
+ ///
+ public Type Expected { get; private set; }
+
+ ///
+ /// Actual achievment type under
+ ///
+ ///
+ ///
+ public Type Actual { get; private set; }
+
+ public AchievmentTypeExcetion(string message, string achievmentId, Type expectedType, Type actualType) : base(message, achievmentId)
+ {
+ Expected = expectedType;
+ Actual = actualType;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Achievments/AchievmentException.cs.meta b/Achievments/AchievmentException.cs.meta
new file mode 100644
index 0000000..b09eea7
--- /dev/null
+++ b/Achievments/AchievmentException.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 241344322b9771049b6962e48ac98085
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Achievments/AchievmentManager.cs b/Achievments/AchievmentManager.cs
index 64f26cd..56e361a 100644
--- a/Achievments/AchievmentManager.cs
+++ b/Achievments/AchievmentManager.cs
@@ -264,7 +264,7 @@ namespace NEG.Utils.Achievments
/// throws an if either there is no achievment under id or achievment under id is of a different type
public T GetAchievmentForId(string id) where T : AchievmentData
{
- return CheckAchievmentType(GetAchievmentForId(id));
+ return ValidateAchievmentType(GetAchievmentForId(id));
}
///
@@ -281,15 +281,15 @@ namespace NEG.Utils.Achievments
}
else
{
- throw new ApplicationException($"Invalid achivment id {id}");
+ throw new AchievmentException($"Invalid achivment id {id}", id);
}
}
- private T CheckAchievmentType(AchievmentData data) where T : AchievmentData
+ private T ValidateAchievmentType(AchievmentData data) where T : AchievmentData
{
if (data is not T convetred)
{
- throw new ApplicationException($"Attempting to perform an operation on an invalid achievment type. Expected {typeof(T)} got {data.GetType()}");
+ throw new AchievmentTypeExcetion($"Attempting to perform an operation on an invalid achievment type. Expected {typeof(T)} got {data.GetType()}", data.Achivment.Id, typeof(T), data.GetType());
}
return convetred;
}
diff --git a/Achievments/IAchievmentCallbackReciever.cs b/Achievments/IAchievmentCallbackReciever.cs
index 6c6a87d..133a4e5 100644
--- a/Achievments/IAchievmentCallbackReciever.cs
+++ b/Achievments/IAchievmentCallbackReciever.cs
@@ -11,13 +11,13 @@ namespace NEG.Utils.Achievments
///
/// Called when an achivment is completed
///
- ///
- void AchievmentCompleted(AchievmentData achivment);
+ ///
+ void AchievmentCompleted(AchievmentData achievment);
///
/// Called when achivment progress changes
///
- ///
- void AchievmentStateChanged(AchievmentData achivment);
+ ///
+ void AchievmentStateChanged(AchievmentData achievment);
}
}
\ No newline at end of file