1 /** 2 * Copyright © DiamondMVC 2019 3 * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE) 4 * Author: Jacob Jensen (bausshf) 5 */ 6 module diamond.errors.exceptions.viewexception; 7 8 import diamond.core.apptype; 9 10 static if (isWebServer) 11 { 12 /// Exception thrown by a view. 13 final class ViewException : Exception 14 { 15 private: 16 /// The view name. 17 string _viewName; 18 19 public: 20 /** 21 * Creates a new view exception. 22 * Params: 23 * viewName = The name of the view that threw the error. 24 * throwable = The throwable. 25 * fn = The file. 26 * ln = The line. 27 */ 28 this(string viewName, Throwable throwable, string fn = __FILE__, size_t ln = __LINE__) 29 { 30 _viewName = viewName; 31 32 super("...", fn, ln, throwable); 33 } 34 35 /** 36 * Retrieves a string equivalent to the exception text. 37 * Returns: 38 * A string equivalent to the exception text. 39 */ 40 override string toString() 41 { 42 return "view: " ~ _viewName ~ "\r\n\r\n" ~ super.toString(); 43 } 44 } 45 46 /// Error thrown by a view. 47 final class ViewError : Error 48 { 49 private: 50 /// The view name. 51 string _viewName; 52 53 public: 54 /** 55 * Creates a new view error. 56 * Params: 57 * viewName = The name of the view that threw the error. 58 * throwable = The throwable. 59 * fn = The file. 60 * ln = The line. 61 */ 62 this(string viewName, Throwable throwable, string fn = __FILE__, size_t ln = __LINE__) 63 { 64 _viewName = viewName; 65 66 super("...", fn, ln, throwable); 67 } 68 69 /** 70 * Retrieves a string equivalent to the error text. 71 * Returns: 72 * A string equivalent to the error text. 73 */ 74 override string toString() 75 { 76 return "view: " ~ _viewName ~ "\r\n\r\n" ~ super.toString(); 77 } 78 } 79 }