Skip to content

Commit

Permalink
ROVER-313 Output errors properly when running rover dev (#2384)
Browse files Browse the repository at this point in the history
At the moment we swallow a lot of errors/they only appear in logs,
whereas we should expose them to users so they can fix the problems
themselves.
  • Loading branch information
jonathanrainer authored Feb 4, 2025
1 parent c978a29 commit 5810499
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/command/dev/router/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use futures::StreamExt;
use houston::Credential;
use rover_client::operations::config::who_am_i::{RegistryIdentity, WhoAmIError, WhoAmIRequest};
use rover_client::shared::GraphRef;
use rover_std::{debugln, infoln, RoverStdError};
use rover_client::RoverClientError;
use rover_std::{debugln, errln, infoln, RoverStdError};
use tokio::process::Child;
use tokio::time::sleep;
use tokio_stream::wrappers::UnboundedReceiverStream;
Expand All @@ -23,13 +24,15 @@ use super::watchers::router_config::RouterConfigWatcher;
use crate::command::dev::router::hot_reload::{HotReloadConfig, HotReloadConfigOverrides};
use crate::command::dev::router::watchers::file::FileWatcher;
use crate::composition::events::CompositionEvent;
use crate::composition::CompositionError;
use crate::options::LicenseAccepter;
use crate::subtask::{Subtask, SubtaskRunStream, SubtaskRunUnit};
use crate::utils::client::StudioClientConfig;
use crate::utils::effect::exec::ExecCommandConfig;
use crate::utils::effect::install::InstallBinary;
use crate::utils::effect::read_file::ReadFile;
use crate::utils::effect::write_file::{WriteFile, WriteFileRequest};
use crate::RoverError;

pub struct RunRouter<S> {
pub(crate) state: S,
Expand Down Expand Up @@ -322,8 +325,18 @@ impl RunRouter<state::Watch> {

let composition_messages =
tokio_stream::StreamExt::filter_map(composition_messages, |event| match event {
CompositionEvent::Error(CompositionError::Build { source, .. }) => {
let number_of_subgraphs = source.len();
let error_to_output = RoverError::from(RoverClientError::BuildErrors {
source,
num_subgraphs: number_of_subgraphs,
});
eprintln!("{}", error_to_output);
None
}
CompositionEvent::Error(err) => {
tracing::error!("Composition error {:?}", err);
errln!("Error occurred when composing supergraph\n{}", err);
None
}
CompositionEvent::Success(success) => Some(RouterUpdateEvent::SchemaChanged {
Expand Down

0 comments on commit 5810499

Please sign in to comment.