Repository: pybamm-team/PyBaMM

Issue:
Better error on unrecognised parameter set
Doing `pybamm.ParameterValues("bad")` gives `ValueError: Invalid Parameter Value`. It would be better to say something like `ValueError: 'bad' is not a recognised parameter set` and possibly list the valid options (including custom parameter sets that have been registered as entry points).

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/pybamm-team/PyBaMM/pull/4208?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 99.55%. Comparing base [(`205ca81`)](https://app.codecov.io/gh/pybamm-team/PyBaMM/commit/205ca815b0b65e04ea77472ccfb2ef0e586f80cc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team) to head [(`34c7869`)](https://app.codecov.io/gh/pybamm-team/PyBaMM/commit/34c786976d7a089197357820e35cd05503e0f75a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff            @@
##           develop    #4208   +/-   ##
========================================
  Coverage    99.55%   99.55%           
========================================
  Files          288      288           
  Lines        21857    21858    +1     
========================================
+ Hits         21760    21761    +1     
  Misses          97       97           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/pybamm-team/PyBaMM/pull/4208?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pybamm-team).

rtimms: @all-contributors please add @Ubham16 for code
allcontributors[bot]: @rtimms 

I've put up [a pull request](https://github.com/pybamm-team/PyBaMM/pull/4213) to add @Ubham16! :tada:

Patch:
diff --git a/pybamm/parameters/parameter_values.py b/pybamm/parameters/parameter_values.py
index c8011c735..57ebf6505 100644
--- a/pybamm/parameters/parameter_values.py
+++ b/pybamm/parameters/parameter_values.py
@@ -65,7 +65,10 @@ class ParameterValues:
                 values.pop("chemistry", None)
                 self.update(values, check_already_exists=False)
             else:
-                raise ValueError("Invalid Parameter Value")
+                valid_sets = "\n".join(pybamm.parameter_sets.keys())
+                raise ValueError(
+                    f"'{values}' is not a valid parameter set. Parameter set must be one of:\n{valid_sets}"
+                )
 
         # Initialise empty _processed_symbols dict (for caching)
         self._processed_symbols = {}


Test patch:
diff --git a/tests/unit/test_parameters/test_parameter_values.py b/tests/unit/test_parameters/test_parameter_values.py
index 7b5fd38bf..28b8aa2ef 100644
--- a/tests/unit/test_parameters/test_parameter_values.py
+++ b/tests/unit/test_parameters/test_parameter_values.py
@@ -43,7 +43,7 @@ class TestParameterValues(TestCase):
             pybamm.ParameterValues(None, chemistry="lithium-ion")
 
         # junk param values rejected
-        with self.assertRaisesRegex(ValueError, "Invalid Parameter Value"):
+        with self.assertRaisesRegex(ValueError, "'Junk' is not a valid parameter set."):
             pybamm.ParameterValues("Junk")
 
     def test_repr(self):