Formatting
This commit is contained in:
parent
f7726c0ad9
commit
16c609cd20
3 changed files with 33 additions and 48 deletions
|
@ -120,7 +120,7 @@ fn serve(request: &mut Request, collection: &mut Collection) -> IronResult<Respo
|
|||
_ => status::InternalServerError,
|
||||
};
|
||||
return Err(IronError::new(e, status));
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
if !metadata.is_file() {
|
||||
|
|
|
@ -37,9 +37,7 @@ pub struct Directory {
|
|||
}
|
||||
|
||||
impl Directory {
|
||||
pub fn read(collection: &Collection,
|
||||
path: &Path)
|
||||
-> Result<Directory, PError> {
|
||||
pub fn read(collection: &Collection, path: &Path) -> Result<Directory, PError> {
|
||||
let virtual_path = try!(collection.vfs.real_to_virtual(path));
|
||||
let path_string = try!(virtual_path.to_str().ok_or(PError::PathDecoding));
|
||||
|
||||
|
@ -73,8 +71,7 @@ impl Collection {
|
|||
Collection { vfs: Vfs::new() }
|
||||
}
|
||||
|
||||
pub fn load_config(&mut self, config_path: &Path) -> Result<(), PError>
|
||||
{
|
||||
pub fn load_config(&mut self, config_path: &Path) -> Result<(), PError> {
|
||||
// Open
|
||||
let mut config_file = match File::open(config_path) {
|
||||
Ok(c) => c,
|
||||
|
|
24
src/error.rs
24
src/error.rs
|
@ -58,24 +58,12 @@ impl fmt::Display for PError {
|
|||
match *self {
|
||||
PError::Io(ref err) => write!(f, "IO error: {}", err),
|
||||
PError::PathDecoding => write!(f, "Path decoding error"),
|
||||
PError::ConflictingMount => {
|
||||
write!(f, "Mount point already has a target directory")
|
||||
}
|
||||
PError::PathNotInVfs => {
|
||||
write!(f, "Requested path does not index a mount point")
|
||||
}
|
||||
PError::CannotServeDirectory => {
|
||||
write!(f, "Only individual files can be served")
|
||||
}
|
||||
PError::ConfigFileOpenError => {
|
||||
write!(f, "Could not open config file")
|
||||
}
|
||||
PError::ConfigFileReadError => {
|
||||
write!(f, "Could not read config file")
|
||||
}
|
||||
PError::ConfigFileParseError => {
|
||||
write!(f, "Could not parse config file")
|
||||
}
|
||||
PError::ConflictingMount => write!(f, "Mount point already has a target directory"),
|
||||
PError::PathNotInVfs => write!(f, "Requested path does not index a mount point"),
|
||||
PError::CannotServeDirectory => write!(f, "Only individual files can be served"),
|
||||
PError::ConfigFileOpenError => write!(f, "Could not open config file"),
|
||||
PError::ConfigFileReadError => write!(f, "Could not read config file"),
|
||||
PError::ConfigFileParseError => write!(f, "Could not parse config file"),
|
||||
PError::ConfigMountDirsParseError => {
|
||||
write!(f, "Could not parse mount directories in config file")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue