/**
Licensed Materials - Property of IBM
IBM Cognos Products: DOCS
(C) Copyright IBM Corp. 2005, 2007
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
*/
// Copyright (C) 2007 Cognos ULC, an IBM Company. All rights reserved.
// Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
// sn_dg_sdk_headerexception_start_1
using System;
using System.Text;
using cognosdotnet_10_2;
namespace SamplesCommon
{
///
/// Extract the interesting bits from a biBusHeader after a biBusHeader
/// fault.
///
public class HeaderExceptionHelper
{
private CAMException _exception = null;
///
/// Create a HeaderExceptionHelper object.
///
/// The contentManagerService1 object in use during the last exception.
public HeaderExceptionHelper( contentManagerService1 cmService )
{
// Pull the CAM exception out of the biBusHeader.
_exception = cmService.biBusHeaderValue.CAM.exception;
}
///
/// Get the Severity string from this biBusHeader exception.
///
public string Severity {
get {
return _exception.severity.ToString();
}
}
///
/// Get the errorCode string from this biBusHeader exception.
///
public string ErrorCode {
get {
return _exception.errorCodeString;
}
}
///
/// Get the details (messageString) from this biBusHeader exception.
///
public string[] Details {
get {
string[] retval = new string[_exception.messages.Length];
for( int idx = 0; idx < _exception.messages.Length; idx++ ) {
retval[idx] = _exception.messages[idx].messageString;
}
return retval;
}
}
///
/// Get the promptInfo (and useful captions/displayObjects inside) to
/// facilitate prompting the user, if this is a recoverable exception.
///
public promptInfo PromptInfo {
get {
return _exception.promptInfo;
}
}
///
/// Convert this biBusHeader exception into a string for printing.
///
/// A string representation of the biBusHeader exception.
public override string ToString() {
StringBuilder str = new StringBuilder();
str.AppendFormat( "Severity: {0}\n", Severity );
str.AppendFormat( "ErrorCode: {0}\n", ErrorCode );
str.AppendFormat( "Details:\n" );
foreach( string s in Details ) {
str.AppendFormat( "\t{0}\n", s );
}
return str.ToString();
}
///
/// Convert a biBusHeader exception into a string.
///
/// This is the same as creating a HeaderExceptionHelper and calling
/// its ToString() method.
///
/// The Service object that threw the exception.
/// A string representation of the biBusHeader exception.
static public string ConvertToString( contentManagerService1 cmService ) {
HeaderExceptionHelper exception = new HeaderExceptionHelper( cmService );
return exception.ToString();
}
}
}
// sn_dg_sdk_headerexception_end_1