示例#1
0
 /**
  * Converts an application error to the service specific exception.
  *
  * @param ApplicationError $application_error The application error
  *
  * @return mixed An exception that corresponds to the application error.
  *
  * @access private
  */
 private static function applicationErrorToException($application_error)
 {
     switch ($application_error->getApplicationError()) {
         case ErrorCode::UNKNOWN_SCOPE:
             return new \InvalidArgumentException('An unknown scope was supplied.');
         case ErrorCode::BLOB_TOO_LARGE:
             return new \InvalidArgumentException('The supplied blob was too long.');
         case ErrorCode::DEADLINE_EXCEEDED:
             return new AppIdentityException('The deadline for the call was exceeded.');
         case ErrorCode::NOT_A_VALID_APP:
             return new AppIdentityException('The application is not valid.');
         case ErrorCode::UNKNOWN_ERROR:
             return new AppIdentityException('There was an unknown error using the AppIdentity service.');
         case ErrorCode::GAIAMINT_NOT_INITIAILIZED:
             return new AppIdentityException('There was a GAIA error using the AppIdentity service.');
         case ErrorCode::NOT_ALLOWED:
             return new AppIdentityException('The call is not allowed.');
         default:
             return new AppIdentityException('The AppIdentity service threw an unexpected error.');
     }
 }
示例#2
0
 private static function applicationErrorToException(ApplicationError $error)
 {
     switch ($error->getApplicationError()) {
         case ErrorCode::INVALID_REQUEST:
             return new LogException('Invalid Request');
         case ErrorCode::STORAGE_ERROR:
             return new LogException('Storage Error');
         default:
             return new LogException('Error Code: ' . $error->getApplicationError());
     }
 }