Function errorDisplay
Attribute to customize error display of an interface method.
The first template parameter takes a function that maps an exception and an optional field name to a single error type. The result of this function will then be passed as the error parameter to the method referenced by the second template parameter.
The field parameter, if present, will be set to null if the exception was thrown after the field validation has finished.
Prototype
fghfgherrorDisplay(alias DISPLAY_METHOD)() @property;
Example
Simple error message display
void getForm(string _error = null) { //render!("form.dt", _error); } @errorDisplay!getForm void postForm(string name) { if (name.length == 0) throw new Exception("Name must not be empty"); redirect("/"); }
Example
Error message display with a matching
struct FormError { string error; string field; } void getForm(FormError _error = FormError.init) { //render!("form.dt", _error); } // throws an error if the submitted form value is not a valid integer @errorDisplay!getForm void postForm(int ingeter) { redirect("/"); }
Authors
Sönke Ludwig
Copyright
© 2013-2014 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.