All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xins.client.UnacceptableErrorCodeXINSCallException Maven / Gradle / Ivy

The newest version!
/*
 * $Id: UnacceptableErrorCodeXINSCallException.java,v 1.14 2012/03/15 21:07:39 agoubard Exp $
 *
 * See the COPYRIGHT file for redistribution and use restrictions.
 */
package org.xins.client;

import org.xins.common.MandatoryArgumentChecker;

import org.xins.common.service.TargetDescriptor;

/**
 * Exception that indicates an error code was received from the server-side
 * that is not expected at the client-side.
 *
 * @version $Revision: 1.14 $ $Date: 2012/03/15 21:07:39 $
 * @author Ernst de Haan
 *
 * @since XINS 1.2.0
 */
public class UnacceptableErrorCodeXINSCallException
extends UnacceptableResultXINSCallException {

   /**
    * Constructs a new UnacceptableErrorCodeXINSCallException
    * based on a XINSCallResultData instance.
    *
    * @param request
    *    the original request, cannot be null.
    *
    * @param target
    *    descriptor for the target that was attempted to be called, cannot be
    *    null.
    *
    * @param duration
    *    the call duration in milliseconds, must be >= 0.
    *
    * @param resultData
    *    the result data, cannot be null.
    *
    * @throws IllegalArgumentException
    *    if request     == null
    *          || target      == null
    *          || duration  < 0
    *          || resultData  == null
    *          || resultData.{@link XINSCallResult#getErrorCode()
    *             getErrorCode()} == null.
    */
   public UnacceptableErrorCodeXINSCallException(
      XINSCallRequest    request,
      TargetDescriptor   target,
      long               duration,
      XINSCallResultData resultData
   ) throws IllegalArgumentException {

      super(request, target, duration, resultData, getDetail(resultData));
   }

   /**
    * Constructs a detail message for the constructor to pass up to the
    * superconstructor.
    *
    * @param result
    *    the {@link XINSCallResultData} that is has an error code set that is
    *    considered unacceptable, never null.
    *
    * @return
    *    the detail message, never null.
    *
    * @throws IllegalArgumentException
    *    if result == null
    *          || result.{@link XINSCallResultData#getErrorCode()
    *             getErrorCode()} == null.
    */
   private static String getDetail(XINSCallResultData result)
   throws IllegalArgumentException {

      // Check preconditions
      MandatoryArgumentChecker.check("result", result);
      if (result.getErrorCode() == null) {
         throw new IllegalArgumentException("result.getErrorCode() == null");
      }

      // Generate detail message
      return "Error code \""
           + result.getErrorCode()
           + "\" is not acceptable for this function.";
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy