Use thiserror and anyhow for command-level error types

This commit is contained in:
Lucien Greathouse
2020-03-16 21:13:38 -07:00
parent 363f95ba14
commit f69096dadb
7 changed files with 69 additions and 132 deletions

View File

@@ -3,25 +3,15 @@ use std::{
sync::Arc,
};
use anyhow::Result;
use memofs::Vfs;
use snafu::Snafu;
use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor};
use crate::{cli::ServeCommand, serve_session::ServeSession, web::LiveServer};
const DEFAULT_PORT: u16 = 34872;
#[derive(Debug, Snafu)]
pub struct ServeError(Error);
#[derive(Debug, Snafu)]
enum Error {}
pub fn serve(options: ServeCommand) -> Result<(), ServeError> {
Ok(serve_inner(options)?)
}
fn serve_inner(options: ServeCommand) -> Result<(), Error> {
pub fn serve(options: ServeCommand) -> Result<()> {
let vfs = Vfs::new_default();
let session = Arc::new(ServeSession::new(vfs, &options.absolute_project()));