1 /** 2 Exceptions, thrown by dpeq code. 3 4 Copyright: Copyright Boris-Barboris 2017. 5 License: MIT 6 Authors: Boris-Barboris 7 */ 8 9 module dpeq.exceptions; 10 11 import dpeq.result: Notice; 12 13 14 /// mixes in standard exception constructors that call super correctly 15 mixin template ExceptionConstructors() 16 { 17 @safe pure nothrow this(string message, 18 Throwable next, 19 string file =__FILE__, 20 size_t line = __LINE__) 21 { 22 super(message, next, file, line); 23 } 24 25 @safe pure nothrow this(string message, 26 string file =__FILE__, 27 size_t line = __LINE__, 28 Throwable next = null) 29 { 30 super(message, file, line, next); 31 } 32 } 33 34 class PsqlClientException: Exception 35 { 36 mixin ExceptionConstructors; 37 } 38 39 class PsqlSerializationException: PsqlClientException 40 { 41 mixin ExceptionConstructors; 42 } 43 44 class PsqlConnectionClosedException: PsqlSocketException 45 { 46 mixin ExceptionConstructors; 47 } 48 49 class PsqlSocketException: Exception 50 { 51 mixin ExceptionConstructors; 52 } 53 54 /// Thrown by $(D dpeq.PSQLConnection.pollMessages) when ErrorResponse message 55 /// is received (immediately after parse or delayed until ReadyForQuery message). 56 class PsqlErrorResponseException: Exception 57 { 58 /// Contents of ErrorResponse message that caused this exception. 59 Notice notice; 60 61 @safe pure nothrow this(Notice n, 62 Throwable next, 63 string file =__FILE__, 64 size_t line = __LINE__) 65 { 66 super(n.message, next, file, line); 67 notice = n; 68 } 69 70 @safe pure nothrow this(Notice n, 71 string file =__FILE__, 72 size_t line = __LINE__, 73 Throwable next = null) 74 { 75 super(n.message, file, line, next); 76 notice = n; 77 } 78 }