mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 15:15:25 +02:00
Support SystemOperationFailedException with plaintext error message
This commit is contained in:
parent
f1bb98a548
commit
589ced638d
1 changed files with 34 additions and 20 deletions
|
@ -35,7 +35,7 @@ public class SystemOperationFailedException extends SystemRemoteMessageException
|
|||
|
||||
/**
|
||||
* Default Constructor.
|
||||
* 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.
|
||||
*
|
||||
* @param remoteException the initial cause of this exception
|
||||
*/
|
||||
|
@ -43,9 +43,20 @@ 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.
|
||||
* Clients are encouraged to use the more specific constructor with pluginId and operationPerformed instead of this one.
|
||||
*
|
||||
* @param remoteException the initial cause of this exception
|
||||
*/
|
||||
|
@ -64,27 +75,30 @@ public class SystemOperationFailedException extends SystemRemoteMessageException
|
|||
|
||||
private static SystemMessage getMyMessage(String pluginId, String operationPerformed, Exception remoteException) {
|
||||
|
||||
String message = remoteException.getMessage();
|
||||
if (message == null) {
|
||||
message = remoteException.getClass().getName();
|
||||
String message = operationPerformed;
|
||||
String secondLevel = null;
|
||||
if (remoteException != null) {
|
||||
message = remoteException.getMessage();
|
||||
if (message == null) {
|
||||
message = remoteException.getClass().getName();
|
||||
}
|
||||
Throwable cause = remoteException.getCause();
|
||||
if (cause != null) {
|
||||
secondLevel = cause.getMessage();
|
||||
if (secondLevel == null) {
|
||||
secondLevel = cause.getClass().getName();
|
||||
if (secondLevel.equals(message)) {
|
||||
secondLevel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operationPerformed != null) {
|
||||
// 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);
|
||||
|
||||
String secondLevel = null;
|
||||
Throwable cause = remoteException.getCause();
|
||||
if (cause != null) {
|
||||
secondLevel = cause.getMessage();
|
||||
if (secondLevel == null) {
|
||||
secondLevel = cause.getClass().getName();
|
||||
if (secondLevel.equals(message)) {
|
||||
secondLevel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operationPerformed != null) {
|
||||
// FIXME Use Java MessageFormat for better formatting
|
||||
secondLevel = (secondLevel != null) ? operationPerformed + " : " + secondLevel : operationPerformed; //$NON-NLS-1$
|
||||
}
|
||||
SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_OPERATION_FAILED,
|
||||
IStatus.ERROR, msgTxt, secondLevel);
|
||||
return msg;
|
||||
|
|
Loading…
Add table
Reference in a new issue