Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

Improve OpMatchingException error messages - #24

Merged
hinerm merged 3 commits into
masterfrom
scijava/scijava-ops/improve-errors
Jun 9, 2021
Merged

hinerm merged 3 commits into
masterfrom
scijava/scijava-ops/improve-errors

Conversation

@gselzer

@gselzer gselzer commented Sep 28, 2020 •

Copy link
Copy Markdown
Member

This PR improves the error messages resulting from Op matching, making it easier to tune Op requests. Current improvements focus in two areas

  • Identifying when two Ops conflict over a particular Op request. OpMatchingExceptions now describe all Ops that fully satisfy the request.
  • Clearly identifying when an Op was not provided due to the unavailability of an OpDependency. A new class, DependencyMatchingException, was created to chain the errors resulting from a failing dependency. DependencyMatchingException.getMessage() will return a String combining its own message with the messages of DependencyMatchingExceptions that are (super)causes of the returned exception. This helps users recognize that the problem does not lie with the requested Op, but instead lies with one of that Op's dependencies. An example message, describing an Op test.dependentOp that depends on test.missingDependencyOp, which in turn depends on test.nonexistingOp, is included below:
Could not instantiate dependency of: org.scijava.ops.matcher.DependentOp
Dependency identifier: op

Attempted request:
Name: "test.missingDependencyOp", Types: [java.util.function.Function<java.lang.Double, java.lang.Double>]
Input Types: 
		* java.lang.Double
Output Type: 
		* java.lang.Double

Cause:

Could not instantiate dependency of: org.scijava.ops.matcher.MissingDependencyOp
Dependency identifier: op

Attempted request:
Name: "test.nonexistingOp", Types: [java.util.function.Function<java.lang.Double, java.lang.Double>]
Input Types: 
		* java.lang.Double
Output Type: 
		* java.lang.Double

TODO:

  • It would also be nice to make standard OpMatchingExceptions more informational (such as describing the set of parameters that prevented an OpRef from matching a particular OpInfo. This might be difficult, however, as DefaultMatchingService does not really provide us with the flexibility to report this information. It would thus require significant change. This information could also become overwhelming (think, for example, of the overwhelming number of failures upon requesting some Function<X , X> create) to the point where it could cause more confusion than good.

@gselzer
gselzer force-pushed the scijava/scijava-ops/improve-errors branch 3 times, most recently from af4bb4f to 157a4da Compare June 9, 2021 16:08
gselzer added 3 commits June 9, 2021 11:11
This allows us to be more clear about the dependency chain that was not
able to be matched
@gselzer
gselzer force-pushed the scijava/scijava-ops/improve-errors branch from 157a4da to 1f357a5 Compare June 9, 2021 16:11
@hinerm
hinerm marked this pull request as ready for review June 9, 2021 16:18
@hinerm
hinerm merged commit b85d723 into master Jun 9, 2021
hinerm added a commit that referenced this pull request Jun 16, 2021
This PR improves the error messages resulting from Op matching, making it easier to tune Op requests. Current improvements focus in two areas

* Identifying when two Ops conflict over a particular Op request. OpMatchingExceptions now describe all Ops that fully satisfy the request.
* Clearly identifying when an Op was not provided due to the unavailability of an OpDependency. A new class, DependencyMatchingException, was created to chain the errors resulting from a failing dependency. DependencyMatchingException.getMessage() will return a String combining its own message with the messages of DependencyMatchingExceptions that are (super)causes of the returned exception. This helps users recognize that the problem does not lie with the requested Op, but instead lies with one of that Op's dependencies. An example message, describing an Op test.dependentOp that depends on test.missingDependencyOp, which in turn depends on test.nonexistingOp, is included below:

See #24
@hinerm
hinerm deleted the scijava/scijava-ops/improve-errors branch November 22, 2022 19:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants