Skip to content

Commit 9d99a35

Browse files
committed
Handle exceptions in CompatibilityUtil
Since exceptions had not been handled before, problems writing to the preference store prevented bundle activation. Exceptions are now added to the workspace log.
1 parent 098b436 commit 9d99a35

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

com.eclipsesource.jshint.ui/src/com/eclipsesource/jshint/ui/internal/CompatibilityUtil.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CompatibilityUtil {
3838
private CompatibilityUtil() {
3939
}
4040

41-
static void run() throws CoreException {
41+
static void run() {
4242
Preferences preferences = PreferencesFactory.getWorkspacePreferences();
4343
Version previousVersion = getPreviousVersion( preferences );
4444
Version currentVersion = getCurrentVersion();
@@ -57,20 +57,31 @@ static Version getCurrentVersion() {
5757
return Activator.getDefault().getBundle().getVersion();
5858
}
5959

60-
private static void firstRun( Version previousVersion, Version currentVersion ) throws CoreException {
60+
private static void firstRun( Version previousVersion, Version currentVersion ) {
6161
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
6262
for( IProject project : projects ) {
6363
if( project.isAccessible() ) {
64-
updateObsoleteBuilderId( project );
65-
movePropertiesFromObsoleteNode( project );
66-
turnEnabledToIncludes( project );
67-
if( !isGreaterOrEqual( previousVersion, 0, 9, 4 ) ) {
68-
fixPre09FolderExcludePatterns( project );
64+
try {
65+
updateProject( project, previousVersion, currentVersion );
66+
} catch( CoreException exception ) {
67+
Activator.logError( "Failed to update project metadata:" + project.getName(), exception );
6968
}
7069
}
7170
}
7271
}
7372

73+
private static void updateProject( IProject project,
74+
Version previousVersion,
75+
Version currentVersion ) throws CoreException
76+
{
77+
updateObsoleteBuilderId( project );
78+
movePropertiesFromObsoleteNode( project );
79+
turnEnabledToIncludes( project );
80+
if( !isGreaterOrEqual( previousVersion, 0, 9, 4 ) ) {
81+
fixPre09FolderExcludePatterns( project );
82+
}
83+
}
84+
7485
private static boolean isGreaterOrEqual( Version version, int major, int minor, int micro ) {
7586
boolean result = false;
7687
if( version != null ) {
@@ -138,9 +149,13 @@ private static List<String> createBasicIncludesList() {
138149
return list;
139150
}
140151

141-
private static void setVersion( Preferences preferences, Version version ) throws CoreException {
152+
private static void setVersion( Preferences preferences, Version version ) {
142153
preferences.put( KEY_PLUGIN_VERSION, version.toString() );
143-
flushPreferences( preferences );
154+
try {
155+
flushPreferences( preferences );
156+
} catch( CoreException exception ) {
157+
Activator.logError( "Failed to store new jshint-eclipse version in workspace", exception );
158+
}
144159
}
145160

146161
private static String[] readPreferencesKeys( Preferences preferences ) throws CoreException {

0 commit comments

Comments
 (0)