[jboss-jira] [JBoss JIRA] (LOGTOOL-124) Ability to provide exception producer
David Lloyd (JIRA)
issues at jboss.org
Thu Dec 15 10:52:01 EST 2016
David Lloyd created LOGTOOL-124:
-----------------------------------
Summary: Ability to provide exception producer
Key: LOGTOOL-124
URL: https://issues.jboss.org/browse/LOGTOOL-124
Project: Log Tool
Issue Type: Feature Request
Reporter: David Lloyd
Priority: Minor
Sometimes you must use the same exception message for many different types of exception. It would be nice if you could give a parameter which can produce an exception, like this:
{code}
public interface MyLogs {
// ...
@Message(id = 1234, "The operation failed due to %s")
<T extends Throwable> T operationFailed(@Producer Function<String, T> fn, String thing);
}
{code}
And later at usage:
{code}
// ...
throw MyLogs.log.operationFailed(IOException::new, "thingy");
{code}
A valid function parameter must return a type which is equal or assignable to the return type, and is assignable to Throwable. Other than that, it can be treated the same as as if you were dealing with a constructor class that has exactly one constructor, using the same matching/inference logic, meaning you could also accept BiFunction which accepts two arguments.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list