lib/metadataprotocol.js
function writeExtendedException(requestId, requestType, exceptionMessage, exceptionType, exceptionData) {
	var encodedExc = protocol.encodeMetadataException(exceptionType);
	if (encodedExc == exceptions.CREDITS) {
		return protocol.implodeMessage(requestId, requestType, encodedExc,
			protocol.encodeString(exceptionMessage),
			protocol.encodeString(exceptionData.clientCode),
			protocol.encodeString(exceptionData.clientMessage));
	} else if (encodedExc === exceptions.CONFLICTING_SESSION) {
		return protocol.implodeMessage(requestId, requestType, encodedExc,
			protocol.encodeString(exceptionMessage),
			protocol.encodeString(exceptionData.clientCode),
			protocol.encodeString(exceptionData.clientMessage),
			protocol.encodeString(exceptionData.conflictingSessionId));
	} else {
		return protocol.implodeMessage(requestId, requestType, encodedExc,
			protocol.encodeString(exceptionMessage));
	}
}
function writeExtendedException(requestId, requestType, exceptionMessage, exceptionType, exceptionData) {
	var encodedExc = protocol.encodeMetadataException(exceptionType);
	if (encodedExc == exceptions.CREDITS) {
		return protocol.implodeMessage(requestId, requestType, encodedExc,
			protocol.encodeString(exceptionMessage),
			protocol.encodeString(exceptionData.clientCode),
			protocol.encodeString(exceptionData.clientMessage));
	} else if (encodedExc === exceptions.CONFLICTING_SESSION) {
		return protocol.implodeMessage(requestId, requestType, encodedExc,
			protocol.encodeString(exceptionMessage),
			protocol.encodeString(exceptionData.clientCode),
			protocol.encodeString(exceptionData.clientMessage),
			protocol.encodeString(exceptionData.conflictingSessionId));
	} else {
		return protocol.implodeMessage(requestId, requestType, encodedExc,
			protocol.encodeString(exceptionMessage));
	}
}
function writeExtendedException ( requestId , requestType , exceptionMessage , exceptionType , exceptionData ) { var encodedExc = protocol . encodeMetadataException ( exceptionType ) ; if ( encodedExc == exceptions . CREDITS ) { return protocol . implodeMessage ( requestId , requestType , encodedExc , protocol . encodeString ( exceptionMessage ) , protocol . encodeString ( exceptionData . clientCode ) , protocol . encodeString ( exceptionData . clientMessage ) ) ; } else if ( encodedExc === exceptions . CONFLICTING_SESSION ) { return protocol . implodeMessage ( requestId , requestType , encodedExc , protocol . encodeString ( exceptionMessage ) , protocol . encodeString ( exceptionData . clientCode ) , protocol . encodeString ( exceptionData . clientMessage ) , protocol . encodeString ( exceptionData . conflictingSessionId ) ) ; } else { return protocol . implodeMessage ( requestId , requestType , encodedExc , protocol . encodeString ( exceptionMessage ) ) ; } }
Encodes an unsuccessful reply that may involve an exception with parameters.

@param {String} requestId the originating request id
@param {String} requestType the originating request method name
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: access, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private
Encodes an unsuccessful reply that may involve an exception with parameters .