|
37 | 37 | import org.eclipse.jface.dialogs.MessageDialog; |
38 | 38 |
|
39 | 39 | /** |
40 | | - * Our sample handler extends AbstractHandler, an IHandler base class. |
41 | 40 | * @see org.eclipse.core.commands.IHandler |
42 | 41 | * @see org.eclipse.core.commands.AbstractHandler |
43 | 42 | */ |
@@ -80,9 +79,25 @@ protected IStatus run(IProgressMonitor monitor) { |
80 | 79 | showErrorDialogOnUIThread(shell,"Unable to read ServiceStack reference from project."); |
81 | 80 | return Status.CANCEL_STATUS; |
82 | 81 | } |
83 | | - |
84 | 82 | 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 | + } |
86 | 101 | String baseUrl = options.get("BaseUrl"); |
87 | 102 | options.remove("BaseUrl"); |
88 | 103 | String updatedCode = ""; |
|
0 commit comments