Skip to content

Commit 885fc1d

Browse files
committed
More error handling and cleanup.
1 parent 195f3eb commit 885fc1d

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/ServiceStackEclipse/plugin.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
<extension
2222
point="org.eclipse.ui.commands">
2323
<command
24-
id="net.servicestack.eclipse.commands.sampleCommand"
24+
id="net.servicestack.eclipse.commands.updateReferenceCommand"
2525
name="Update ServiceStack Reference">
2626
</command>
2727
</extension>
2828
<extension
2929
point="org.eclipse.ui.bindings">
3030
<key
31-
commandId="net.servicestack.eclipse.commands.sampleCommand"
31+
commandId="net.servicestack.eclipse.commands.updateReferenceCommand"
3232
contextId="org.eclipse.ui.contexts.window"
3333
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
3434
sequence="M1+6">
@@ -39,9 +39,9 @@
3939
<menuContribution
4040
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
4141
<command
42-
commandId="net.servicestack.eclipse.commands.sampleCommand"
42+
commandId="net.servicestack.eclipse.commands.updateReferenceCommand"
4343
icon="icons/logo-16.png"
44-
id="net.servicestack.eclipse.menus.sampleCommand"
44+
id="net.servicestack.eclipse.menus.updateReferenceMenu"
4545
mnemonic="M">
4646
<visibleWhen>
4747
<with
@@ -59,7 +59,7 @@
5959
<extension point="org.eclipse.ui.handlers">
6060
<handler
6161
class="net.servicestack.eclipse.handlers.UpdateReferenceHandler"
62-
commandId="net.servicestack.eclipse.commands.sampleCommand">
62+
commandId="net.servicestack.eclipse.commands.updateReferenceCommand">
6363
<visibleWhen>
6464
<with
6565
variable="selection">

src/ServiceStackEclipse/src/net/servicestack/eclipse/handlers/UpdateReferenceHandler.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.eclipse.jface.dialogs.MessageDialog;
3838

3939
/**
40-
* Our sample handler extends AbstractHandler, an IHandler base class.
4140
* @see org.eclipse.core.commands.IHandler
4241
* @see org.eclipse.core.commands.AbstractHandler
4342
*/
@@ -80,9 +79,25 @@ protected IStatus run(IProgressMonitor monitor) {
8079
showErrorDialogOnUIThread(shell,"Unable to read ServiceStack reference from project.");
8180
return Status.CANCEL_STATUS;
8281
}
83-
8482
INativeTypesHandler nativeTypesHandler = new JavaNativeTypesHandler();
85-
Map<String,String> options = nativeTypesHandler.parseComments(fileContents);
83+
if(!nativeTypesHandler.isFileAServiceStackReference(fileContents)) {
84+
showErrorDialogOnUIThread(shell,"Unable to read ServiceStack reference file Options. Have you deleted the Options header?");
85+
return Status.CANCEL_STATUS;
86+
}
87+
88+
89+
Map<String,String> options = null;
90+
try {
91+
options = nativeTypesHandler.parseComments(fileContents);
92+
}
93+
catch(IllegalArgumentException e) {
94+
showErrorDialogOnUIThread(shell,"Unable to read BaseUrl option from ServiceStack reference file. Check BaseUrl in the Options header.");
95+
return Status.CANCEL_STATUS;
96+
}
97+
catch(Exception e) {
98+
showErrorDialogOnUIThread(shell,"Unable to read reference options. Check Options comment.");
99+
return Status.CANCEL_STATUS;
100+
}
86101
String baseUrl = options.get("BaseUrl");
87102
options.remove("BaseUrl");
88103
String updatedCode = "";

src/ServiceStackEclipse/src/net/servicestack/eclipse/nativetypes/JavaNativeTypesHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public Map<String, String> parseComments(String codeOutput) {
3434
}
3535
}
3636

37+
if(baseUrl == null) {
38+
throw new IllegalArgumentException("Missing BaseURL value");
39+
}
3740
if(!baseUrl.endsWith("/")) {
3841
baseUrl += "/";
3942
}

0 commit comments

Comments
 (0)