Fix clippy::result-large-err.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -54,7 +54,7 @@ async fn handle_command(services: Arc<Services>, command: CommandInput) -> Proce
|
|||||||
|
|
||||||
async fn process_command(services: Arc<Services>, input: &CommandInput) -> ProcessorResult {
|
async fn process_command(services: Arc<Services>, input: &CommandInput) -> ProcessorResult {
|
||||||
let (command, args, body) = match parse(&services, input) {
|
let (command, args, body) = match parse(&services, input) {
|
||||||
| Err(error) => return Err(error),
|
| Err(error) => return Err(Box::new(error)),
|
||||||
| Ok(parsed) => parsed,
|
| Ok(parsed) => parsed,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,12 +90,14 @@ async fn process_command(services: Arc<Services>, input: &CommandInput) -> Proce
|
|||||||
write!(&mut logs, "Command failed with error:\n```\n{error:#?}\n```")
|
write!(&mut logs, "Command failed with error:\n```\n{error:#?}\n```")
|
||||||
.expect("output buffer");
|
.expect("output buffer");
|
||||||
|
|
||||||
Err(reply(RoomMessageEventContent::notice_markdown(logs), context.reply_id))
|
Err(Box::new(reply(
|
||||||
|
RoomMessageEventContent::notice_markdown(logs),
|
||||||
|
context.reply_id,
|
||||||
|
)))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::result_large_err)]
|
|
||||||
fn handle_panic(error: &Error, command: &CommandInput) -> ProcessorResult {
|
fn handle_panic(error: &Error, command: &CommandInput) -> ProcessorResult {
|
||||||
let link =
|
let link =
|
||||||
"Please submit a [bug report](https://github.com/matrix-construct/tuwunel/issues/new). \
|
"Please submit a [bug report](https://github.com/matrix-construct/tuwunel/issues/new). \
|
||||||
@@ -103,7 +105,7 @@ fn handle_panic(error: &Error, command: &CommandInput) -> ProcessorResult {
|
|||||||
let msg = format!("Panic occurred while processing command:\n```\n{error:#?}\n```\n{link}");
|
let msg = format!("Panic occurred while processing command:\n```\n{error:#?}\n```\n{link}");
|
||||||
let content = RoomMessageEventContent::notice_markdown(msg);
|
let content = RoomMessageEventContent::notice_markdown(msg);
|
||||||
error!("Panic while processing command: {error:?}");
|
error!("Panic while processing command: {error:?}");
|
||||||
Err(reply(content, command.reply_id.as_deref()))
|
Err(Box::new(reply(content, command.reply_id.as_deref())))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse and process a message from the admin room
|
/// Parse and process a message from the admin room
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ pub type ProcessorFuture = Pin<Box<dyn Future<Output = ProcessorResult> + Send>>
|
|||||||
/// events which have digested any prior errors. The wrapping preserves whether
|
/// events which have digested any prior errors. The wrapping preserves whether
|
||||||
/// the command failed without interpreting the text. Ok(None) outputs are
|
/// the command failed without interpreting the text. Ok(None) outputs are
|
||||||
/// dropped to produce no response.
|
/// dropped to produce no response.
|
||||||
pub type ProcessorResult = Result<Option<CommandOutput>, CommandOutput>;
|
pub type ProcessorResult = Result<Option<CommandOutput>, Box<CommandOutput>>;
|
||||||
|
|
||||||
/// Alias for the output structure.
|
/// Alias for the output structure.
|
||||||
pub type CommandOutput = RoomMessageEventContent;
|
pub type CommandOutput = RoomMessageEventContent;
|
||||||
@@ -199,14 +199,18 @@ impl Service {
|
|||||||
|
|
||||||
async fn handle_command(&self, command: CommandInput) {
|
async fn handle_command(&self, command: CommandInput) {
|
||||||
match self.process_command(command).await {
|
match self.process_command(command).await {
|
||||||
|
| Err(output) => self.handle_command_output(*output).await,
|
||||||
|
| Ok(Some(output)) => self.handle_command_output(output).await,
|
||||||
| Ok(None) => debug!("Command successful with no response"),
|
| Ok(None) => debug!("Command successful with no response"),
|
||||||
| Ok(Some(output)) | Err(output) => self
|
|
||||||
.handle_response(output)
|
|
||||||
.await
|
|
||||||
.unwrap_or_else(default_log),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn handle_command_output(&self, content: RoomMessageEventContent) {
|
||||||
|
self.handle_response(content)
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(default_log);
|
||||||
|
}
|
||||||
|
|
||||||
async fn process_command(&self, command: CommandInput) -> ProcessorResult {
|
async fn process_command(&self, command: CommandInput) -> ProcessorResult {
|
||||||
let handle = &self
|
let handle = &self
|
||||||
.handle
|
.handle
|
||||||
|
|||||||
Reference in New Issue
Block a user