1 module exceptions;
2 
3 import std.exception;
4 
5 /++
6  + Abstract. If you want to catch simply all stream interruptions.
7  +/
8 abstract class InterruptedStreamException : Exception {
9     mixin basicExceptionCtors;
10 }
11 
12 /++
13  + The input stream was not closed properly.
14  + Somebody is trying to read from it, but the stream can't give anything by some reason.
15  +/
16 class InterruptedInputException : InterruptedStreamException {
17     mixin basicExceptionCtors;
18 }
19 
20 /++
21  + You are trying to read from a closed input stream
22  + with a method, that has mandatory result by design (non-optional, non-nullable).
23  + The stream has no data for you, but you read from it.
24  + This is almost certainly a bug, but, sometimes, this could be used for the recoverable behaviour.
25  + <b>Note, the class is not derived from InterruptedStreamException.</b>
26  +/
27 class ClosedInputStreamException : Exception {
28     mixin basicExceptionCtors;
29 }
30 
31 /++
32  + You are trying to write to a closed output stream.
33  + This is almost certainly a bug, but, sometimes, this could be used for the recoverable behaviour.
34  + <b>Note, the class is not derived from InterruptedStreamException.</b>
35  +/
36 class ClosedOutputStreamException : Exception {
37     mixin basicExceptionCtors;
38 }
39 
40 /++
41  + The output stream was not closed properly.
42  + Somebody is trying to write into it, but it can't receive the data by some reason.
43  +/
44 class InterruptedOutputException : InterruptedStreamException {
45     mixin basicExceptionCtors;
46 }
47 
48 /++
49  + Abstract. Just a base to differ the user things from the system things.
50  +/
51 abstract class UserBehaviourException : Exception {
52     mixin basicExceptionCtors;
53 }
54 
55 /++
56  + If you have some good reason to not use `assert(0)`.<br/>
57  + In other words, if you really think you need a recoverable `assert(0)`.<br/>
58  + Be careful.
59  + See <a href="https://forum.dlang.org/post/mailman.1239.1490287548.31550.digitalmars-d@puremagic.com" target="_blank">the discussion</a>.
60  +/
61 final class RecoverableHellException : Exception {
62     /// Just use it without arguments.
63     this(string file = __FILE__, size_t line = __LINE__) pure nothrow @nogc @safe {
64         super("Bloody hell.", file, line);
65     }
66 }