mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
- avoid thrown exception by doing preventive check
This commit is contained in:
parent
16269eba9c
commit
0473138b52
1 changed files with 6 additions and 4 deletions
|
@ -103,13 +103,15 @@ public interface ICProjectDescriptionStorageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Version getVersion(IConfigurationElement element, String id, Version defaultValue) throws IllegalArgumentException{
|
private static Version getVersion(IConfigurationElement element, String id, Version defaultValue) throws IllegalArgumentException{
|
||||||
if (defaultValue == null)
|
String value = element.getAttribute(id);
|
||||||
return new Version(element.getAttribute(id));
|
if (value==null)
|
||||||
Version v = defaultValue;
|
return defaultValue;
|
||||||
|
Version v;
|
||||||
try {
|
try {
|
||||||
v = new Version(element.getAttribute(id));
|
v = new Version(value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// If an exception occurred return the default value
|
// If an exception occurred return the default value
|
||||||
|
v = defaultValue;
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue