-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make getPropertyAsInt throw #3146
Conversation
cpp/include/Ice/Properties.h
Outdated
@@ -82,15 +82,17 @@ namespace Ice | |||
std::string getPropertyWithDefault(std::string_view key, std::string_view value) noexcept; | |||
|
|||
/** | |||
* Get a property as an integer. If the property is not set, 0 is returned. | |||
* Get a property as an integer. If the property is not set, 0 is returned. Throws PropertyException if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the function throws belongs to the @throws tag, not the summary.
cpp/include/Ice/Properties.h
Outdated
|
||
/** | ||
* Get an Ice property as an integer. If the property is not set, its default value is returned. | ||
* Get an Ice property as an integer. If the property is not set, its default value is returned. Throws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
cpp/include/Ice/Properties.h
Outdated
@@ -99,13 +101,14 @@ namespace Ice | |||
int getIcePropertyAsInt(std::string_view key); | |||
|
|||
/** | |||
* Get a property as an integer. If the property is not set, the given default value is returned. | |||
* Get a property as an integer. If the property is not set, the given default value is returned. Throws | |||
* PropertyException if the property value is not a valid integer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
csharp/src/Ice/Properties.cs
Outdated
@@ -165,15 +165,17 @@ public string getPropertyWithDefault(string key, string value) | |||
|
|||
/// <summary> | |||
/// Get a property as an integer. | |||
/// If the property is not set, 0 is returned. | |||
/// If the property is not set, 0 is returned. Throws PropertyException if the property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The summary should not describe what the method throws.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still have to move the exception docs to exception
tag
@@ -215,6 +216,7 @@ public int getPropertyAsInt(String key) { | |||
* | |||
* @param key The property key. | |||
* @return The property value interpreted as an integer, or the default value. | |||
* @throws PropertyException Raised if the property value is not a valid integer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to document what we throw if the key doesn't designate a valid Ice property.
@@ -70,5 +70,15 @@ function run($args) | |||
test($ex->getMessage() == "unknown Ice property: Ice.UnknownProperty"); | |||
} | |||
echo "ok\n"; | |||
|
|||
echo "testing that trying to read a non-numeric value as an int throws... "; | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try block should not include the "arrange" part of the test.
ruby/test/Ice/properties/Client.rb
Outdated
@@ -101,5 +101,15 @@ def run(args) | |||
end | |||
puts "ok" | |||
|
|||
print "testing that trying to read a non-numeric value as an int throws... " | |||
begin | |||
properties = Ice.createProperties(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -34,14 +34,14 @@ public protocol Properties: AnyObject { | |||
/// - parameter _: `String` The property key. | |||
/// | |||
/// - returns: `Int32` - The property value interpreted as an integer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to document exception.
|
||
/// Get an Ice property as an integer. If the property is not set,its default value is returned. | ||
/// | ||
/// - parameter key: `String` The property key. | ||
/// | ||
/// - returns: `Int32` - The property value interpreted as an integer, or the default value. | ||
func getIcePropertyAsInt(_ key: String) -> Int32 | ||
func getIcePropertyAsInt(_ key: String) throws -> Int32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you still have to update JavaScript
csharp/src/Ice/Properties.cs
Outdated
@@ -165,15 +165,17 @@ public string getPropertyWithDefault(string key, string value) | |||
|
|||
/// <summary> | |||
/// Get a property as an integer. | |||
/// If the property is not set, 0 is returned. | |||
/// If the property is not set, 0 is returned. Throws PropertyException if the property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still have to move the exception docs to exception
tag
csharp/src/Ice/Properties.cs
Outdated
/// </summary> | ||
/// <param name="key">The property key.</param> | ||
/// <returns>The property value interpreted as an integer.</returns> | ||
public int getPropertyAsInt(string key) => getPropertyAsIntWithDefault(key, 0); | ||
|
||
/// <summary> | ||
/// Get an Ice property as an integer. | ||
/// If the property is not set, its default value is returned. | ||
/// If the property is not set, its default value is returned. Throws PropertyException if the property is not a | ||
/// known Ice property or the value is not a valid integer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, move the exception docs to exception
tag
This PR updates
getPropertyAsInt
to throw aPropertyException
in the event that the property cannot be converted to an integer.