org.xins.client.UnacceptableErrorCodeXINSCallException Maven / Gradle / Ivy
/*
* $Id: UnacceptableErrorCodeXINSCallException.java,v 1.7 2006/08/28 09:12:30 agoubard Exp $
*
* Copyright 2003-2006 Orange Nederland Breedband B.V.
* 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.7 $ $Date: 2006/08/28 09:12:30 $
* @author Ernst de Haan
*
* @since XINS 1.2.0
*/
public class UnacceptableErrorCodeXINSCallException
extends UnacceptableResultXINSCallException {
//-------------------------------------------------------------------------
// Class functions
//-------------------------------------------------------------------------
/**
* 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 final 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.";
}
//-------------------------------------------------------------------------
// Constructors
//-------------------------------------------------------------------------
/**
* 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));
}
//-------------------------------------------------------------------------
// Methods
//-------------------------------------------------------------------------
}