protected function handleApplicationError($e) {
    switch($e->getApplicationError()) {
      case ErrorCode::INTERNAL_ERROR:
      case ErrorCode::BAD_REQUEST:
        throw new \RuntimeException(
            "Mail Service Error: " . $e->getMessage());
      case ErrorCode::UNAUTHORIZED_SENDER:
        $error = sprintf("Mail Service Error: Sender (%s) is not an " .
                         "authorized email address.",
                         htmlspecialchars($this->message->getSender()));
        throw new \InvalidArgumentException($error);
      case ErrorCode::INVALID_ATTACHMENT_TYPE:
        throw new \InvalidArgumentException(
            "Mail Service Error: Invalid attachment type.");
      case ErrorCode::INVALID_HEADER_NAME:
        throw new \InvalidArgumentException(
            "Mail Service Error: Invalid header name.");
      default:
        throw $e;
    }
  }
protected function handleApplicationError($e) {
    switch($e->getApplicationError()) {
      case ErrorCode::INTERNAL_ERROR:
      case ErrorCode::BAD_REQUEST:
        throw new \RuntimeException(
            "Mail Service Error: " . $e->getMessage());
      case ErrorCode::UNAUTHORIZED_SENDER:
        $error = sprintf("Mail Service Error: Sender (%s) is not an " .
                         "authorized email address.",
                         htmlspecialchars($this->message->getSender()));
        throw new \InvalidArgumentException($error);
      case ErrorCode::INVALID_ATTACHMENT_TYPE:
        throw new \InvalidArgumentException(
            "Mail Service Error: Invalid attachment type.");
      case ErrorCode::INVALID_HEADER_NAME:
        throw new \InvalidArgumentException(
            "Mail Service Error: Invalid header name.");
      default:
        throw $e;
    }
  }
protected function handleApplicationError ( $ e ) { switch ( $ e -> getApplicationError ( ) ) { case ErrorCode :: INTERNAL_ERROR : case ErrorCode :: BAD_REQUEST : throw new \ RuntimeException ( "Mail Service Error: " . $ e -> getMessage ( ) ) ; case ErrorCode :: UNAUTHORIZED_SENDER : $ error = sprintf ( "Mail Service Error: Sender (%s) is not an " . "authorized email address." , htmlspecialchars ( $ this -> message -> getSender ( ) ) ) ; throw new \ InvalidArgumentException ( $ error ) ; case ErrorCode :: INVALID_ATTACHMENT_TYPE : throw new \ InvalidArgumentException ( "Mail Service Error: Invalid attachment type." ) ; case ErrorCode :: INVALID_HEADER_NAME : throw new \ InvalidArgumentException ( "Mail Service Error: Invalid header name." ) ; default : throw $ e ; } }
Handles application errors generated by the RPC call.

@param ApplicationError An exception caught during the RPC call.
@throws \RuntimeException If there was an internal error or bad request.
@throws \InvalidArgumentException If there was an unauthorized sender,
an invalid attachment type, or an invalid header name.
@throws ApplicationError If the error is not one of the above.
Handles application errors generated by the RPC call .