Log EppExceptions in EppController at INFO (vs FlowRunner at WARNING)

The logging for exceptions in FlowRunner - always at WARNING - has long been sub-optimal.  For EppExceptions it's too aggressive/spammy to log at WARNING because it's generally not actionable - EppException gets properly thrown for all kinds of ordinary reasons (trying to create a resource when one already exists with that foreign key) and/or for client misbehavior that we can't control (sending bad parameter values, etc.).  For non-EppException RuntimeExceptions, it's redundant with existing logging in EppController.

This CL resolves this by removing that logging in FlowRunner entirely in favor of the EppController logging, where we're now logging EppExceptions at INFO in parallel with the existing logging of RuntimeExceptions at SEVERE.  This has the benefit that we're now logging EppExceptions that come from FlowPicker (by way of EppExceptionInProviderException),  which previously were unlogged.

Note however that this does mean that in places where we run FlowRunner without EppController - exclusively test code as it stands today - we'd no longer be logging EppExceptions.  If that seems like a loss, we could either reinstate logging there (at INFO) and just deal with redundant messages for most EppExceptions, or we could add it manually to places where we call FlowRunner.run() in tests and avoid the redundancy that way.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154733365
This commit is contained in:
nickfelt 2017-05-01 11:00:14 -07:00 committed by Ben McIlwain
parent 11e7374c0f
commit f640d765e8
6 changed files with 196 additions and 76 deletions

View file

@ -14,7 +14,6 @@
package google.registry.flows;
import static com.google.common.base.Throwables.getStackTraceAsString;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.xml.XmlTransformer.prettyPrint;
@ -100,17 +99,13 @@ public class FlowRunner {
}
return output;
} catch (EppException e) {
throw new RuntimeException(e);
throw new EppRuntimeException(e);
}
}});
} catch (DryRunException e) {
return e.output;
} catch (RuntimeException e) {
logger.warning(getStackTraceAsString(e));
if (e.getCause() instanceof EppException) {
throw (EppException) e.getCause();
}
throw e;
} catch (EppRuntimeException e) {
throw e.getCause();
}
}
@ -122,4 +117,16 @@ public class FlowRunner {
this.output = output;
}
}
/** Exception for explicitly propagating an EppException out of the transactional {@code Work}. */
private static class EppRuntimeException extends RuntimeException {
EppRuntimeException(EppException cause) {
super(cause);
}
@Override
public synchronized EppException getCause() {
return (EppException) super.getCause();
}
}
}