On Thu, 12 Jun 2014 15:43:16 GMT, Sönke Ludwig wrote:

This should work:

ul!= info.errors
// or
u1
    != info.errors

or this:

ul
    |!{info.errors}

I would expect |!= #{info.errors} to result in a compiler error. I'll look into that.

Yes it works now thank you. I got a bit confused with diet or d code after != .

And by the way does anybody have any advice about the best way to pass errors or notifications to different HTTP functions?
Hardcode them where they are displayed and pass error codes in queries?
Pass the error strings as parameters (but this doesn't work with res.redirect) or as query parameters in the url?

I usually pass them by parameter, but that indeed has the issue of not working well with redirects. The good thing is that this is supported by vibe.web.web, though, saving some boilerplate code:

@path("/")
void getIndex(string _error = null)
{
	render!("index.dt", _error);
}

@errorDisplay!getIndex
void postLogin(string username, string password)
{
	enforceHTTP(username.length > 0, HTTPStatus.forbidden,
		"User name must not be empty.");
	enforceHTTP(password == "secret", HTTPStatus.forbidden,
		"Invalid password.");
	m_loginUser = username;
	redirect("/profile");
}

Any exception will automatically cause getIndex to be called for rendering the error message. Later it's also planned to add direct parameter validation support that will call the error display function without any exceptions involved (for efficiency).

I have my own system for validation errors and notifications related to user input without using exceptions and i use vibe.d error handling for all the rest.
In your example the errorDisplay! property is assigned to the postLogin function but i guess i can later assign other functions' errors to different pages like:

  @path("/")
 void getIndex(string _error = null)
 {
 	render!("index.dt", _error);
 }
 
 @errorDisplay!getIndex
 void postLogin(string username, string password)
 {
 	enforceHTTP(username.length > 0, HTTPStatus.forbidden,
 		"User name must not be empty.");
 	enforceHTTP(password == "secret", HTTPStatus.forbidden,
 		"Invalid password.");
 	m_loginUser = username;
 	redirect("/profile");
 }
@path("/another")
 void getAnother(string _error = null)
 {
 	render!("other.dt", _error);
 }
@errorDisplay!getAnother
void postSomething()
{
...
}
The web interface generator seems nice i should take some time and change my code.