1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#![feature(proc_macro_hygiene, decl_macro)] #![deny(warnings, intra_doc_link_resolution_failure)] #![deny(clippy::all, clippy::pedantic)] #![forbid(unsafe_code)] #[macro_use] extern crate log; #[macro_use] extern crate ref_thread_local; #[macro_use] extern crate rocket; #[macro_use] extern crate rust_embed; use mruby::MrbError; use std::error; use std::fmt; mod adapter; mod interpreter; mod request; mod response; mod rubygems; mod server; use rubygems::nemesis; pub use server::{Builder, Mount}; #[derive(Debug)] pub enum Error { CannotCreateApp, FailedLaunch(String), Mrb(MrbError), NoRoute, RackResponse, Status, } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Error::CannotCreateApp => write!(f, "cannot create Rack app"), Error::FailedLaunch(err) => write!(f, "failed to launch server: {}", err), Error::Mrb(err) => write!(f, "{}", err), Error::NoRoute => write!(f, "no matching route"), Error::RackResponse => write!(f, "malformed Rack response tuple"), Error::Status => write!(f, "status is not a valid HTTP status code"), } } } impl error::Error for Error { fn description(&self) -> &str { "nemesis error" } fn cause(&self) -> Option<&dyn error::Error> { match self { Error::Mrb(inner) => Some(inner), _ => None, } } } impl From<MrbError> for Error { fn from(error: MrbError) -> Self { Error::Mrb(error) } }