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 + The output stream was not closed properly. 22 + Somebody is trying to write into it, but it can't receive the data by some reason. 23 +/ 24 class InterruptedOutputException : InterruptedStreamException { 25 mixin basicExceptionCtors; 26 } 27 28 /++ 29 + You are trying to read from a closed input stream 30 + with a method, that has mandatory result by design (non-optional, non-nullable). 31 + The stream has no data for you, but you read from it. 32 + This is almost certainly a bug, but, sometimes, this could be used for the recoverable behaviour. 33 + <b>Note, the class is not derived from InterruptedStreamException.</b> 34 +/ 35 class ClosedInputStreamException : Exception { 36 mixin basicExceptionCtors; 37 } 38 39 /++ 40 + You are trying to write to a closed output stream. 41 + This is almost certainly a bug, but, sometimes, this could be used for the recoverable behaviour. 42 + <b>Note, the class is not derived from InterruptedStreamException.</b> 43 +/ 44 class ClosedOutputStreamException : Exception { 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 }