News for hackers. Stuff that matters.
Re:Rust web framework, Iron by viraptor on Sunday August 16, 2015 @06:24PM (#10070489)
You mean in the handler? The return value has to be of a type `IronResult<Response>`. That means it can be either `Ok(...)` for success or `Err(...)` for failure.

In other languages/frameworks (python/pecan for example) you'd throw an exception in case of things going wrong. In Rust exceptions are for very exceptional things only (it's called panic). So the more calm way is just to return `Err(...)`.

It's not a function, it's more like a tagged union (in rust called an enum). So in practice it's like C's union, but you do know which member was chosen and only that one is accessible.

Re:Rust web framework, Iron by GyrosOfWar on Monday August 17, 2015 @04:49AM (#10071896)
Small correction: Rust doesn't have exceptions. panic!() crashes the current thread with an optional error message, but it doesn't do stack traces and there's no try/catch in the language (there's the try!() macro, but it works with Result<T, E> values, has nothing to do with panics).
Re:Rust web framework, Iron by heinrich5991 on Monday August 17, 2015 @05:41AM (#10072059)
It records stack traces. Use the environment variable `RUST_BACKTRACE=1` to print them.