Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling example #302

Open
flosse opened this issue Nov 26, 2015 · 3 comments
Open

Error handling example #302

flosse opened this issue Nov 26, 2015 · 3 comments

Comments

@flosse
Copy link

flosse commented Nov 26, 2015

It would be great to have an example with proper error handling.
E.g. how can I use a custom AppError within my routes? I'd like to write something like

fn post_foo<'a>(req: &mut nickel::Request<Data>,
                          res: nickel::Response<'a,Data>)
                          -> MiddlewareResult<'a,Data> {
  let db = res.server_data().db.clone();
  let foo = try!(something(&pool));
  let bar = try!(precedure(&foo));
  try!(baz(bar))
}

Each of the methods return a AppError and somewhere central would be a custom mapping of the HTTP status codes and error messages. How can I achieve this?

@flosse
Copy link
Author

flosse commented Nov 28, 2015

related: #115, #123

@flosse
Copy link
Author

flosse commented Nov 30, 2015

In #304 I started with an example that needs to be improved. Could you help me?

@Ryman
Copy link
Member

Ryman commented Nov 30, 2015

Left a comment on the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants