Add some logging/error-handling for opener errors! (#745)

After seeing an issue with the opener not opening, it was strange to see
that there was no logging or error handling! This PR aims to solve that.
This commit is contained in:
utrain
2023-07-26 18:10:02 -04:00
committed by GitHub
parent f6fc5599c0
commit d0e48d9bdc
2 changed files with 36 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
# Rojo Changelog # Rojo Changelog
## Unreleased Changes ## Unreleased Changes
* On failing to open a file from Roblox Studio, it is now logged appropriately instead of being ignored ([#745]).
* Significantly improved performance of `rojo sourcemap`. ([#668]) * Significantly improved performance of `rojo sourcemap`. ([#668])
* Fixed the diff visualizer of connected sessions. ([#674]) * Fixed the diff visualizer of connected sessions. ([#674])
* Fixed disconnected session activity. ([#675]) * Fixed disconnected session activity. ([#675])
@@ -21,6 +22,7 @@
* Added better support for `Font` properties ([#731]) * Added better support for `Font` properties ([#731])
* Add new plugin template to the `init` command ([#738]) * Add new plugin template to the `init` command ([#738])
[#745]: https://github.com/rojo-rbx/rojo/pull/745
[#668]: https://github.com/rojo-rbx/rojo/pull/668 [#668]: https://github.com/rojo-rbx/rojo/pull/668
[#674]: https://github.com/rojo-rbx/rojo/pull/674 [#674]: https://github.com/rojo-rbx/rojo/pull/674
[#675]: https://github.com/rojo-rbx/rojo/pull/675 [#675]: https://github.com/rojo-rbx/rojo/pull/675

View File

@@ -4,6 +4,7 @@
use std::{collections::HashMap, fs, path::PathBuf, str::FromStr, sync::Arc}; use std::{collections::HashMap, fs, path::PathBuf, str::FromStr, sync::Arc};
use hyper::{body, Body, Method, Request, Response, StatusCode}; use hyper::{body, Body, Method, Request, Response, StatusCode};
use opener::OpenError;
use rbx_dom_weak::types::Ref; use rbx_dom_weak::types::Ref;
use crate::{ use crate::{
@@ -236,7 +237,39 @@ impl ApiService {
} }
}; };
let _ = opener::open(script_path); match opener::open(&script_path) {
Ok(()) => {}
Err(error) => match error {
OpenError::Io(io_error) => {
return json(
ErrorResponse::internal_error(format!(
"Attempting to open {} failed because of the following io error: {}",
script_path.display(),
io_error
)),
StatusCode::INTERNAL_SERVER_ERROR,
)
}
OpenError::ExitStatus {
cmd,
status,
stderr,
} => {
return json(
ErrorResponse::internal_error(format!(
r#"The command '{}' to open '{}' failed with the error code '{}'.
Error logs:
{}"#,
cmd,
script_path.display(),
status,
stderr
)),
StatusCode::INTERNAL_SERVER_ERROR,
)
}
},
};
json_ok(&OpenResponse { json_ok(&OpenResponse {
session_id: self.serve_session.session_id(), session_id: self.serve_session.session_id(),