Caught the exception when a version is malformed in target file#2157
Caught the exception when a version is malformed in target file#2157nburnwal09 wants to merge 2 commits intoeclipse-pde:masterfrom
Conversation
7e72db5 to
a606e61
Compare
a606e61 to
91283ae
Compare
|
@HannesWell @laeubi The test case is failing for |
|
@ptziegler can you also have a look? |
#2187 is supposed to improve the failing test. |
| TargetEditor_4=Target Editor | ||
| TargetEditor_5=Unable to load target definition model. Fix the target definition model in Source View. | ||
| TargetEditor_6=The editor input ''{0}'' is not supported. | ||
| TargetEditor_7=Unable to parse the IU version |
There was a problem hiding this comment.
| TargetEditor_7=Unable to parse the IU version | |
| TargetEditor_7=Unable to parse the IU version. Fix the target definition model in Source View. |
I generally not only like if an error message tells me what's wrong, but also how to fix it.
| } catch (IllegalArgumentException e) { | ||
| fTarget = service.newTarget(); | ||
| throw new CoreException(Status.error(e.getMessage(), e)); |
There was a problem hiding this comment.
| } catch (IllegalArgumentException e) { | |
| fTarget = service.newTarget(); | |
| throw new CoreException(Status.error(e.getMessage(), e)); | |
| } |
I don't think catching the exception here is a good idea. If you do this, the editor will automatically switch to the source tab without showing the error dialog.
Additionally you can freely switch from the source tab to any other tab, without the dialog appearing. You need to go back to the source tab first and only then will the dialog appear, when trying to switch to a different tab again.
Without this catch block, the editor tries to open the definition tab, show the error dialog and then switches to the source tab.
91283ae to
15c1235
Compare
|
@ptziegler |
|
It would seem good for the user to know which IU and which version string is causing the problem (if that isn't already diagnosed by an error marker that draw attention to the location). |
|
Sorry this comment was meant for other PR. Please ignore it. |
|
@nburnwal09 Apologies for the slow response. I played around with the change and noticed that it's not really possible to save the editor, even after the version has been corrected. I assume that's why you initially caught the exception in If so, then the catch block is apparently still needed. But instead of converting it to a CoreException, I would rethrow it as is, in order to avoid the side effects described in #2157 (comment) e.g. private ITargetDefinition loadTargetDefinition() throws CoreException {
ITargetPlatformService service = getTargetPlatformService();
try {
if (fInput instanceof IFileEditorInput) {
ITargetHandle fileHandle = service.getTarget(((IFileEditorInput) fInput).getFile());
fTarget = fileHandle.getTargetDefinition();
} else if (fInput instanceof IURIEditorInput) {
ITargetHandle externalTarget = service.getTarget(((IURIEditorInput) fInput).getURI());
fTarget = externalTarget.getTargetDefinition();
}
} catch (CoreException | IllegalArgumentException e) {
fTarget = service.newTarget();
throw e;
}
PlatformUI.getWorkbench().getDisplay().asyncExec(
() -> TargetEditor.this.getTargetChangedListener().contentsChanged(fTarget, this, true, false));
return fTarget;
}
@merks The problem is that the error itself is thrown by Equinox. So there is little that can be done on the PDE with regards to the error message. The invalid version is shown in the underlying exception, which at least to me is sufficient to find the invalid IU.
|
|
@ptziegler
Yes, you you are right. The correction of editor didn't save the editor.
But somehow I didn't see any difference with your suggested change too((maybe some problem with my local Eclipse). Let me go through it once again. Will update the change then |
15c1235 to
f9de7b9
Compare
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
|
@ptziegler sorry for replying late, got catch up with other work items. |

Issue: #1945
Exception is caught to open the target editor when a version is malformed.