Show a crash dialog when the editor panics (#362)

* Show a crash dialog when the editor panics

Closes #357

* Suppress console usage lints

* Proxy cleanup and comments
This commit is contained in:
Keavon Chambers
2021-08-31 18:34:19 -07:00
parent c8389bbae1
commit d290aaf712
16 changed files with 212 additions and 32 deletions

View File

@@ -202,7 +202,13 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
Ok(document) => {
self.load_document(document, responses);
}
Err(e) => responses.push_back(FrontendMessage::DisplayError { description: e.to_string() }.into()),
Err(e) => responses.push_back(
FrontendMessage::DisplayError {
title: "Failed to open document".to_string(),
description: e.to_string(),
}
.into(),
),
}
}
GetOpenDocumentsList => {

View File

@@ -12,7 +12,8 @@ pub enum FrontendMessage {
SetActiveTool { tool_name: String, tool_options: Option<ToolOptions> },
SetActiveDocument { document_index: usize },
UpdateOpenDocumentsList { open_documents: Vec<String> },
DisplayError { description: String },
DisplayError { title: String, description: String },
DisplayPanic { title: String, description: String },
DisplayConfirmationToCloseDocument { document_index: usize },
DisplayConfirmationToCloseAllDocuments,
UpdateCanvas { document: String },

View File

@@ -41,8 +41,10 @@ impl Editor {
pub fn handle_message<T: Into<Message>>(&mut self, message: T) -> Vec<FrontendMessage> {
self.dispatcher.handle_message(message);
let mut responses = Vec::new();
std::mem::swap(&mut responses, &mut self.dispatcher.responses);
responses
}
}