Make ServeSession::new fallible

This commit is contained in:
Lucien Greathouse
2020-03-26 12:07:44 -07:00
parent 9c790eddd7
commit 03c297190d
4 changed files with 10 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ pub fn build(options: BuildCommand) -> Result<(), anyhow::Error> {
let vfs = Vfs::new_default(); let vfs = Vfs::new_default();
let session = ServeSession::new(vfs, &options.absolute_project()); let session = ServeSession::new(vfs, &options.absolute_project())?;
let mut cursor = session.message_queue().cursor(); let mut cursor = session.message_queue().cursor();
{ {

View File

@@ -18,7 +18,7 @@ const DEFAULT_PORT: u16 = 34872;
pub fn serve(global: GlobalOptions, options: ServeCommand) -> Result<()> { pub fn serve(global: GlobalOptions, options: ServeCommand) -> Result<()> {
let vfs = Vfs::new_default(); let vfs = Vfs::new_default();
let session = Arc::new(ServeSession::new(vfs, &options.absolute_project())); let session = Arc::new(ServeSession::new(vfs, &options.absolute_project())?);
let port = options let port = options
.port .port

View File

@@ -22,7 +22,7 @@ pub fn upload(options: UploadCommand) -> Result<(), anyhow::Error> {
let vfs = Vfs::new_default(); let vfs = Vfs::new_default();
let session = ServeSession::new(vfs, &options.absolute_project()); let session = ServeSession::new(vfs, &options.absolute_project())?;
let tree = session.tree(); let tree = session.tree();
let inner_tree = tree.inner(); let inner_tree = tree.inner();

View File

@@ -8,6 +8,7 @@ use std::{
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use memofs::Vfs; use memofs::Vfs;
use rbx_dom_weak::RbxInstanceProperties; use rbx_dom_weak::RbxInstanceProperties;
use thiserror::Error;
use crate::{ use crate::{
change_processor::ChangeProcessor, change_processor::ChangeProcessor,
@@ -90,7 +91,7 @@ impl ServeSession {
/// The project file is expected to be loaded out-of-band since it's /// The project file is expected to be loaded out-of-band since it's
/// currently loaded from the filesystem directly instead of through the /// currently loaded from the filesystem directly instead of through the
/// in-memory filesystem layer. /// in-memory filesystem layer.
pub fn new<P: AsRef<Path>>(vfs: Vfs, start_path: P) -> Self { pub fn new<P: AsRef<Path>>(vfs: Vfs, start_path: P) -> Result<Self, ServeSessionError> {
let start_path = start_path.as_ref(); let start_path = start_path.as_ref();
let start_time = Instant::now(); let start_time = Instant::now();
@@ -152,7 +153,7 @@ impl ServeSession {
tree_mutation_receiver, tree_mutation_receiver,
); );
Self { Ok(Self {
change_processor, change_processor,
start_time, start_time,
session_id, session_id,
@@ -161,7 +162,7 @@ impl ServeSession {
message_queue, message_queue,
tree_mutation_sender, tree_mutation_sender,
vfs, vfs,
} })
} }
pub fn tree_handle(&self) -> Arc<Mutex<RojoTree>> { pub fn tree_handle(&self) -> Arc<Mutex<RojoTree>> {
@@ -205,3 +206,6 @@ impl ServeSession {
self.root_project.serve_place_ids.as_ref() self.root_project.serve_place_ids.as_ref()
} }
} }
#[derive(Debug, Error)]
pub enum ServeSessionError {}