summaryrefslogtreecommitdiff
path: root/Exception.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-09-05 01:01:24 +1000
committerJake Mannens <jake@asger.xyz>2023-09-05 01:01:24 +1000
commitacb74202f5391272c2e1823dfe04a044c7f7a9a7 (patch)
tree09dc032ba526306d8916035bf92336c095246741 /Exception.cs
parent1b080819b26e4e84e5e9c88445806e43698b6757 (diff)
Tag names and aliases are now verified to be unique
Diffstat (limited to 'Exception.cs')
-rw-r--r--Exception.cs34
1 files changed, 32 insertions, 2 deletions
diff --git a/Exception.cs b/Exception.cs
index 2005b1a..1e070eb 100644
--- a/Exception.cs
+++ b/Exception.cs
@@ -10,14 +10,44 @@ public class HBException : Exception {
}
public class ObjectNotFoundException : HBException {
- public Guid Guid { get; set; }
+ public Guid Guid { get; private init; }
public ObjectNotFoundException(Guid guid)
: base($"Object not found: {guid}") {}
}
+public class TagException : HBException {
+ public TagDefinition? TagDefinition { get; private init; }
+
+ public TagException(string message) : base(message) {}
+ public TagException(string message, TagDefinition tagDefinition)
+ : base(message) =>
+ TagDefinition = tagDefinition;
+}
+
+public class TagDuplicateException : TagException {
+ public bool NameExists { get; private init; }
+ public bool AliasExists { get; private init; }
+
+ public TagDuplicateException(bool nameExists, bool aliasExists)
+ : base(GenerateMessage(nameExists, aliasExists)) {
+
+ NameExists = nameExists;
+ AliasExists = aliasExists;
+ }
+
+ private static string GenerateMessage(bool nameExists, bool aliasExists) {
+ if(nameExists && aliasExists)
+ return $"Both tag name and alias already exist!";
+ else if(nameExists)
+ return $"Tag name already exists!";
+ else
+ return $"Tag alias already exists";
+ }
+}
+
public class MediaException : HBException {
- public Media? Media { get; set; }
+ public Media? Media { get; private init; }
public MediaException(string message) : base(message) {}
public MediaException(string message, Media media) : base(message) =>