diff options
author | John St. John <jstjohn@users.noreply.github.com> | 2017-09-27 12:18:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 12:18:32 -0700 |
commit | c9ccc77bcfe434716562ce19838e991025dbe7cc (patch) | |
tree | 3863b7945569c12764eb216287a14f8c323f25ab /src/main/scala/xyz/driver | |
parent | f384bfcf0870c3881a3a4c6afb6eca9baf163077 (diff) | |
parent | c609f18cb0cd209427b4e9c10a507cfa5ed4ea9e (diff) | |
download | driver-core-c9ccc77bcfe434716562ce19838e991025dbe7cc.tar.gz driver-core-c9ccc77bcfe434716562ce19838e991025dbe7cc.tar.bz2 driver-core-c9ccc77bcfe434716562ce19838e991025dbe7cc.zip |
Merge pull request #69 from drivergroup/jstjohn/fix_2_11_compatibility_errorv1.2.1
2_11 does not support .fold on Trys
Diffstat (limited to 'src/main/scala/xyz/driver')
-rw-r--r-- | src/main/scala/xyz/driver/core/trace/ExceptionLoggingSizedBufferingTraceConsumer.scala | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main/scala/xyz/driver/core/trace/ExceptionLoggingSizedBufferingTraceConsumer.scala b/src/main/scala/xyz/driver/core/trace/ExceptionLoggingSizedBufferingTraceConsumer.scala index 64ae15a..399e2c6 100644 --- a/src/main/scala/xyz/driver/core/trace/ExceptionLoggingSizedBufferingTraceConsumer.scala +++ b/src/main/scala/xyz/driver/core/trace/ExceptionLoggingSizedBufferingTraceConsumer.scala @@ -1,9 +1,10 @@ package xyz.driver.core.trace -import com.google.cloud.trace.v1.consumer.{FlushableTraceConsumer} +import com.google.cloud.trace.v1.consumer.FlushableTraceConsumer import com.google.devtools.cloudtrace.v1.Traces import com.typesafe.scalalogging.Logger -import scala.util.Try + +import scala.util.control.NonFatal /** * ExceptionLoggingFlushableTraceConsumer simply wraps a flushable trace consumer and catches/logs any exceptions @@ -19,8 +20,16 @@ class ExceptionLoggingFlushableTraceConsumer(traceConsumer: FlushableTraceConsum log.error(s"Encountered exception logging to google $exception") override def receive(trace: Traces): Unit = - Try(flushableTraceConsumer.receive(trace)).fold(exceptionLogger, identity) + try { + flushableTraceConsumer.receive(trace) + } catch { + case NonFatal(e) => exceptionLogger(e) + } override def flush(): Unit = - Try(flushableTraceConsumer.flush()).fold(exceptionLogger, identity) + try { + flushableTraceConsumer.flush() + } catch { + case NonFatal(e) => exceptionLogger(e) + } } |