Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/crates/relay-bin/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ pub enum Error {
#[error("{0}")]
ConfigError(relay_compiler::errors::Error),

#[error(
"{source}\n\nHint: You can dump the config JSON schema with:\n relay-compiler config-json-schema\n\nFor documentation, see:\n https://relay.dev/docs/getting-started/compiler-config/"
)]
ConfigErrorWithHint { source: Box<Error> },

#[error("Unable to run relay compiler. Error details: \n{details}")]
CompilerError { details: String },

Expand Down
22 changes: 17 additions & 5 deletions compiler/crates/relay-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,23 @@ async fn main() {
}

fn get_config(config_path: Option<PathBuf>) -> Result<Config, Error> {
match config_path {
Some(config_path) => Config::load(config_path).map_err(Error::ConfigError),
None => Config::search(&current_dir().expect("Unable to get current working directory."))
.map_err(Error::ConfigError),
}
let result = match config_path {
Some(config_path) => Config::load(config_path),
None => Config::search(&current_dir().expect("Unable to get current working directory.")),
};
result.map_err(|err| {
let is_config_error = matches!(
err,
CompilerError::ConfigError { .. } | CompilerError::ConfigFileValidation { .. }
);
let mut err = Error::ConfigError(err);
if is_config_error {
err = Error::ConfigErrorWithHint {
source: Box::new(err),
};
}
err
})
}

fn configure_logger(output: OutputKind, terminal_mode: TerminalMode) {
Expand Down
Loading