package com.anchortab.actor

import scala.collection.JavaConversions._

import net.liftweb._
  import common._
  import actor._

import com.anchortab.model.ServiceWrapper

import com.newrelic.api.agent.NewRelic

case class SubscribeEmailToServiceWrapper(serviceWrapper: ServiceWrapper, email: String)

object ServiceWrapperSubmissionActor extends LiftActor with Loggable {
  def messageHandler = {
    case SubscribeEmailToServiceWrapper(serviceWrapper, email) =>
      serviceWrapper.subscribeEmail(email) match {
        case Failure(msg, _, _) =>
          logger.error("Error submitting email " + email + ":" + msg)

          NewRelic.noticeError("External Submission Error", Map(
            "service wrapper" -> serviceWrapper.wrapperIdentifier,
            "email" -> email,
            "error message" -> msg
          ))

        case Empty =>
          logger.error("Got Empty while trying to submit email " + email)

          NewRelic.noticeError("External Submission Empty", Map(
            "service wrapper" -> serviceWrapper.wrapperIdentifier,
            "email" -> email
          ))

        case _ => // Do nothing.
      }
  }
}

package com.anchortab.actor

import scala.collection.JavaConversions._

import net.liftweb._
  import common._
  import actor._

import com.anchortab.model.ServiceWrapper

import com.newrelic.api.agent.NewRelic

case class SubscribeEmailToServiceWrapper(serviceWrapper: ServiceWrapper, email: String)

object ServiceWrapperSubmissionActor extends LiftActor with Loggable {
  def messageHandler = {
    case SubscribeEmailToServiceWrapper(serviceWrapper, email) =>
      serviceWrapper.subscribeEmail(email) match {
        case Failure(msg, _, _) =>
          logger.error("Error submitting email " + email + ":" + msg)

          NewRelic.noticeError("Error submitting email to external service.", Map(
            "service wrapper" -> serviceWrapper.wrapperIdentifier,
            "email" -> email,
            "error message" -> msg
          ))

        case Empty =>
          logger.error("Got Empty while trying to submit email " + email)

          NewRelic.noticeError("Empty while submitting email to external service.", Map(
            "service wrapper" -> serviceWrapper.wrapperIdentifier,
            "email" -> email
          ))

        case _ => // Do nothing.
      }
  }
}

--- 
+++ 
@@ -19,7 +19,7 @@
         case Failure(msg, _, _) =>
           logger.error("Error submitting email " + email + ":" + msg)
 
-          NewRelic.noticeError("Error submitting email to external service.", Map(
+          NewRelic.noticeError("External Submission Error", Map(
             "service wrapper" -> serviceWrapper.wrapperIdentifier,
             "email" -> email,
             "error message" -> msg
@@ -28,7 +28,7 @@
         case Empty =>
           logger.error("Got Empty while trying to submit email " + email)
 
-          NewRelic.noticeError("Empty while submitting email to external service.", Map(
+          NewRelic.noticeError("External Submission Empty", Map(
             "service wrapper" -> serviceWrapper.wrapperIdentifier,
             "email" -> email
           ))
Tweak error messages for submission.
