1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 12:35:22 +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);
}
/**
* 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.
* 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) {
String message = remoteException.getMessage();
String message = operationPerformed;
String secondLevel = null;
if (remoteException != null) {
message = remoteException.getMessage();
if (message == null) {
message = remoteException.getClass().getName();
}
String msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_FAILED, message);
String secondLevel = null;
Throwable cause = remoteException.getCause();
if (cause != null) {
secondLevel = cause.getMessage();
@ -85,6 +96,9 @@ public class SystemOperationFailedException extends SystemRemoteMessageException
// FIXME Use Java MessageFormat for better formatting
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,
IStatus.ERROR, msgTxt, secondLevel);
return msg;