Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Include the parameters names CircularParameterReference error. #242

Merged
merged 1 commit into from
Aug 15, 2024
Merged
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
7 changes: 4 additions & 3 deletions pywr-schema/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub enum SchemaError {
DataTable(#[from] TableError),
#[error("Circular node reference(s) found.")]
CircularNodeReference,
#[error("Circular parameters reference(s) found.")]
CircularParameterReference,
#[error("Circular parameters reference(s) found. Unable to load the following parameters: {0:?}")]
CircularParameterReference(Vec<String>),
#[error("unsupported file format")]
UnsupportedFileFormat,
#[error("Python error: {0}")]
Expand All @@ -56,7 +56,8 @@ pub enum SchemaError {
LoadParameter { name: String, error: String },
#[error("Timeseries error: {0}")]
Timeseries(#[from] TimeseriesError),
#[error("The output of literal constant values is not supported. This is because they do not have a unique identifier such as a name. If you would like to output a constant value please use a `Constant` parameter.")]
#[error("The output of literal constant values is not supported. This is because they do not have a unique identifier such as a name. If you would like to output a constant value please use a `Constant` parameter."
)]
LiteralConstantOutputNotSupported,
#[error("Chrono out of range error: {0}")]
OutOfRange(#[from] chrono::OutOfRange),
Expand Down
3 changes: 2 additions & 1 deletion pywr-schema/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ impl PywrNetwork {

if failed_parameters.len() == n {
// Could not load any parameters; must be a circular reference
return Err(SchemaError::CircularParameterReference);
let failed_names = failed_parameters.iter().map(|p| p.name().to_string()).collect();
return Err(SchemaError::CircularParameterReference(failed_names));
}

remaining_parameters = failed_parameters;
Expand Down