ardite / ardite-core

Core library for Ardite services.
MIT License
3 stars 1 forks source link

Errors #12

Closed calebmer closed 8 years ago

calebmer commented 8 years ago

So, how do we want to handle errors? I'm experimenting a bit with what ardite-rest will look like and I really want to write the following code:

fn handler(&self, driver: Box<Driver>, request: &mut Request) -> IronResult<Response> {
  let schema = driver.schema();
  let mut query = Query::from(request.url.path);
  try!(schema.validate_query(query));
  ...
}

However, schema.validate_query returns an ardite::error::Error and IronResult expects an iron::error::IronError. So my question is, in ardite core, should we implement Into for any possible error type that might be used in server code, or put the Into implementation inside the server code which needs it? Also, is there a way to optionally compile a bit of rust code if the iron crate exists in the project for instance?

svmnotn commented 8 years ago

Well I think that we can implement the From trait for Error where it is needed. The iron crate will always exist in the project since it is a dep. However if we were to make it a feat, then we could only compile said code when the feat is enabled.

calebmer commented 8 years ago

Yeah, I agree that's the best response.