Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //Copyright 2012 Google Inc. All Rights Reserved.
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //       http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
 package com.google.api.ads.adwords.axis.utility.extension.exception;
 
 
 
Exception class for Utility library errors.

Author(s):
Julian Toledo
 
 public final class UtilityLibraryException extends RuntimeException {
 
   private static final long serialVersionUID = -4266064741447695525L;

  
Default Constructor.
 
   public UtilityLibraryException() {
     super();
   }

  
Constructs a new exception with the specified detail message and cause.

Parameters:
message the detail message.
 
   public UtilityLibraryException(String message) {
     super(message);
   }

  
Constructs a new exception with the specified detail message.

Parameters:
message the detail message.
cause the cause
 
   public UtilityLibraryException(String messageThrowable cause) {
     super(message + ": " + ExceptionUtils.getRootCauseMessage(cause),
         ExceptionUtils.getRootCause(cause));
   }

  
Constructs a new exception with the specified cause.

Parameters:
cause the cause
 
   public UtilityLibraryException(Throwable cause) {
     super(cause);
   }

  
Unwraps ApiException and RemoteException exceptions

Parameters:
exception the Exception to unwrap
message custom message to include in the UtilityLibraryException
Throws:
java.rmi.RemoteException for communication-related exceptions
 
   public static void throwUnwrapApiExceptions(Exception exceptionString message)
       throws RemoteException {
     Throwable throwable = Throwables.getRootCause(exception);
     if (throwable.getClass().isAssignableFrom(ApiException.class)) {
       throw (ApiExceptionthrowable;
     }
     if (throwable.getClass().isAssignableFrom(RemoteException.class)) {
       throw (RemoteExceptionthrowable;
     }
     throw new UtilityLibraryException(messageexception);
   }

  
Unwraps ApiException, AxisFault and RemoteException exceptions

Parameters:
exception the Exception to unwrap
message custom message to include in the UtilityLibraryException
Returns:
the unwrapped RemoteException
 
   public static RemoteException getUnwrapApiExceptions(Exception exceptionString message) {
     Throwable throwable = Throwables.getRootCause(exception);
 
     if (throwable.getClass().isAssignableFrom(ApiException.class)
         && !throwable.getClass().equals(RemoteException.class)) {
      return (ApiExceptionthrowable;
    }
    if (throwable.getClass().isAssignableFrom(RemoteException.class)) {
      return (RemoteExceptionthrowable;
    }
    return new RemoteException(message + " " + throwable.getMessage(), throwable);
  }
New to GrepCode? Check out our FAQ X