//==================================================
//
//  Copyright 2017 Siemens Product Lifecycle Management Software Inc. All Rights Reserved.
//
//==================================================

package com.connor.sso.sso.clientx;

import com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException;
import com.teamcenter.soa.client.ExceptionHandler;
import com.teamcenter.soa.exceptions.CanceledOperationException;

/**
 * Implementation of the ExceptionHandler. For ConnectionExceptions (server
 * temporarily down .etc) prompts the user to retry the last request. For other
 * exceptions convert to a RunTime exception.
 */
public class AppXExceptionHandler implements ExceptionHandler
{

	/*
	 * (non-Javadoc)
	 *
	 * @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.schemas.soa._2006_03.exceptions.InternalServerException)
	 */
	public void handleException(InternalServerException ise)
	{
		throw new RuntimeException(ise.getMessage());
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.teamcenter.soa.client.ExceptionHandler#handleException(com.teamcenter.soa.exceptions.CanceledOperationException)
	 */
	public void handleException(CanceledOperationException coe)
	{
		System.out.println("");
		System.out.println("*****");
		System.out.println("Exception caught in com.teamcenter.clientx.AppXExceptionHandler.handleException(CanceledOperationException).");

		// Expecting this from the login tests with bad credentials, and the
		// AnyUserCredentials class not
		// prompting for different credentials
		throw new RuntimeException(coe);
	}

}
