blob: fc3fedad519669b8706509dc5ce68f3a2c348e75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
namespace HyperBooru;
public class HBException : Exception {
public HBException()
: base() {}
public HBException(string message)
: base(message) {}
public HBException(string message, Exception inner)
: base(message, inner) {}
}
public class ObjectNotFoundException : HBException {
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 Guid? MediaId { get; private init; } = null;
public MediaException(string message) : base(message) {}
public MediaException(string message, Guid mediaId) : base(message) =>
MediaId = mediaId;
public MediaException(string message, Media media) : base(message) =>
MediaId = media.Guid;
}
public class MediaCreateException : MediaException {
public MediaCreateException(string message)
: base(message) {}
}
public class ThumbnailException : MediaException {
public ThumbnailException(string message, Guid mediaId)
: base(message, mediaId) {}
public ThumbnailException(string message, Media media)
: base(message, media) {}
}
|