Commit 911ace8
committed
Implemented argument exceptions for argument errors
In a previous commit, I replaced most exceptions in the mapping services with the new `MappingServiceException`, with the idea that implementors could easily catch any expected exception with one specific class.
That rationale generally makes sense, but there is some room for nuance. For example, the exception thrown by the `HierarchicalTopicMappingService`'s `GetHierarchicalRoot()` method is thrown in direct response to invalid data being passed to that method.
In that case, an `ArgumentNullException` (if the parameter was explicitly nulled out) or an `ArgumentOutOfRangeException` (if it refers to an invalid topic path) make more sense.
We _might_ consider replacing the latter with a subclass of `MappingServiceException` in the future to take advantage of the original rationale, but it should definitely be a class that sends a clear signal to the caller that the parameter value that they either passed, or the default value, is invalid.
It's worth noting that this scenario should be rare. It only calls `defaultRoot` as a fallback for scenarios where a page doesn't have a topic associated with it—such as a 404 page—and even then, the default of `Root:Web` is expected to be valid for _most_ implementations.1 parent bc9b7bc commit 911ace8
File tree
1 file changed
+2
-2
lines changed- OnTopic/Mapping/Hierarchical
1 file changed
+2
-2
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
0 commit comments