What does 'Failed to notify action' error message mean? Why is it wrapping my exception?


(Etienne Studer) #1

I have the following code which works correctly:

allprojects { Project project ->

project.tasks.whenTaskAdded { Task task ->

if(task instanceof Tar){

throw new GradleException(“Not allowed to use Tar task type: ${task.name}”)

}

} }

If the GradleException is thrown, the error message looks like this:

Failed to notify action.

Not allowed to use Tar task type: jar

What does the outter exception mean (which is wrapping my exception)?

Thanks and regards, Etienne


(Peter Niederwieser) #2

Seems like the task container doesn’t like it when an exception is thrown from a listener (like your closure) and wraps it in a ListenerNotificationException. (More precisely, the wrapping occurs in ‘BroadcastDispatch.dispatch()’). Except for checked->unchecked exception conversion, I’m not exactly sure why that is necessary.