1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 21:15:23 +02:00

Support SystemOperationFailedException with plaintext error message

This commit is contained in:
Martin Oberhuber 2008-05-06 23:54:20 +00:00
parent f1bb98a548
commit 589ced638d

View file

@ -43,6 +43,17 @@ public class SystemOperationFailedException extends SystemRemoteMessageException
super(getMyMessage(Activator.PLUGIN_ID, null, remoteException), remoteException); super(getMyMessage(Activator.PLUGIN_ID, null, remoteException), remoteException);
} }
/**
* Constructor with plugin ID and plain text failure information. Clients
* are encouraged to use the more specific constructor with pluginId and
* remoteException instead of this one.
*
* @param msg message about failed operation
*/
public SystemOperationFailedException(String pluginId, String msg) {
super(getMyMessage(pluginId, msg, null), null);
}
/** /**
* Constructor with plugin ID. * Constructor with plugin ID.
* Clients are encouraged to use the more specific constructor with pluginId and operationPerformed instead of this one. * Clients are encouraged to use the more specific constructor with pluginId and operationPerformed instead of this one.
@ -64,13 +75,13 @@ public class SystemOperationFailedException extends SystemRemoteMessageException
private static SystemMessage getMyMessage(String pluginId, String operationPerformed, Exception remoteException) { private static SystemMessage getMyMessage(String pluginId, String operationPerformed, Exception remoteException) {
String message = remoteException.getMessage(); String message = operationPerformed;
String secondLevel = null;
if (remoteException != null) {
message = remoteException.getMessage();
if (message == null) { if (message == null) {
message = remoteException.getClass().getName(); message = remoteException.getClass().getName();
} }
String msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_FAILED, message);
String secondLevel = null;
Throwable cause = remoteException.getCause(); Throwable cause = remoteException.getCause();
if (cause != null) { if (cause != null) {
secondLevel = cause.getMessage(); secondLevel = cause.getMessage();
@ -85,6 +96,9 @@ public class SystemOperationFailedException extends SystemRemoteMessageException
// FIXME Use Java MessageFormat for better formatting // FIXME Use Java MessageFormat for better formatting
secondLevel = (secondLevel != null) ? operationPerformed + " : " + secondLevel : operationPerformed; //$NON-NLS-1$ secondLevel = (secondLevel != null) ? operationPerformed + " : " + secondLevel : operationPerformed; //$NON-NLS-1$
} }
}
String msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_FAILED, message);
SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_OPERATION_FAILED, SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_OPERATION_FAILED,
IStatus.ERROR, msgTxt, secondLevel); IStatus.ERROR, msgTxt, secondLevel);
return msg; return msg;