/*******************************************************************************
* Copyright (c) 2006-2010 eBay 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
*******************************************************************************/
package org.ebayopensource.turmeric.runtime.common.exceptions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.ebayopensource.turmeric.common.v1.types.CommonErrorData;
import org.ebayopensource.turmeric.common.v1.types.ErrorMessage;
/**
*
* Exceptions that are generated by framework (on both server and client side)
* are thrown as this type. This is a checked exception
*
* are propagated
* @author smalladi, ichernyshev
*/
public final class ServiceInvocationException extends ServiceException
implements ServiceInvocationExceptionInterface
{
private final List<Throwable> m_clientErrors;
private final Object m_errorResponse;
private final boolean m_isAppOnlyException;
private final String m_requestGuid;
private final Throwable m_applicationException;
private boolean isClientSide; // TODO should be final
/**
* @param msg The default error message.
* @param errorData List of CommonErrorData to be reported by this exception.
* @param clientErrors List of client side ServiceException reported during the invocation.
* @param errorResponse The error response object received from the server.
* @param isAppOnlyException True if the exception is an exception created by service impl logic.
* @param applicationException The application exception returned by the server side.
* @param requestGuid The requestId returned from the server.
* @param cause A Throwable providing the cause of this exception.
*/
public ServiceInvocationException(String msg,
List<CommonErrorData> errorData, List<Throwable> clientErrors,
Object errorResponse, boolean isAppOnlyException, Throwable applicationException,
String requestGuid, Throwable cause)
{
super(ErrorLibraryBaseErrors.getNewErrorMessage(errorData), msg, cause);
m_clientErrors = Collections.unmodifiableList(new ArrayList<Throwable>(clientErrors));
m_errorResponse = errorResponse;
m_isAppOnlyException = isAppOnlyException;
m_applicationException = applicationException;
m_requestGuid = requestGuid;
}
/**
* @param msg The default error message.
* @param errorData List of CommonErrorData to be reported by this exception.
* @param clientErrors List of client side ServiceException reported during the invocation.
* @param errorResponse The error response object received from the server.
* @param isAppOnlyException True if the exception is an exception created by service impl logic.
* @param applicationException The application exception returned by the server side.
* @param requestGuid The requestId returned from the server.
* @param cause A Throwable providing the cause of this exception.
* @param isClientSide True if the exception is originated from the client side.
*/
public ServiceInvocationException(String msg,
List<CommonErrorData> errorData, List<Throwable> clientErrors,
Object errorResponse, boolean isAppOnlyException, Throwable applicationException,
String requestGuid, Throwable cause, boolean isClientSide)
{
super(ErrorLibraryBaseErrors.getNewErrorMessage(errorData), msg, cause);
m_clientErrors = Collections.unmodifiableList(new ArrayList<Throwable>(clientErrors));
m_errorResponse = errorResponse;
m_isAppOnlyException = isAppOnlyException;
m_applicationException = applicationException;
m_requestGuid = requestGuid;
this.isClientSide = isClientSide;
}
/* (non-Javadoc)
* @see org.ebayopensource.turmeric.runtime.common.exceptions.ServiceInvocationExceptionInterface#getClientErrors()
*/
@Override
public List<Throwable> getClientErrors() {
return m_clientErrors;
}
/* (non-Javadoc)
* @see org.ebayopensource.turmeric.runtime.common.exceptions.ServiceInvocationExceptionInterface#getErrorResponse()
*/
@Override
public Object getErrorResponse() {
return m_errorResponse;
}
/* (non-Javadoc)
* @see org.ebayopensource.turmeric.runtime.common.exceptions.ServiceInvocationExceptionInterface#isAppOnlyException()
*/
@Override
public boolean isAppOnlyException() {
return m_isAppOnlyException;
}
/* (non-Javadoc)
* @see org.ebayopensource.turmeric.runtime.common.exceptions.ServiceInvocationExceptionInterface#getRequestGuid()
*/
@Override
public String getRequestGuid() {
return m_requestGuid;
}
/* (non-Javadoc)
* @see org.ebayopensource.turmeric.runtime.common.exceptions.ServiceInvocationExceptionInterface#getApplicationException()
*/
@Override
public Throwable getApplicationException() {
return m_applicationException;
}
/**
* @return the isClientSide
*/
public boolean isClientSide() {
return isClientSide;
}
/**
* serial version UID.
*/
static final long serialVersionUID = 835486766282112209L;
}