Select to view content in your preferred language

Meaning of GeometryEngine nullable return values

151
2
Jump to solution
07-16-2024 05:02 AM
jussih
by
New Contributor

What is the meaning and intention of nullable return values from GeometryEngine, such as: GeometryEngine.distanceOrNull
GeometryEngine.projectOrNull
GeometryEngine.clipOrNull
... and so on, there are many methods like this

Does a null return value mean an error occurred, or that input parameters are invalid somehow?

Typically I would expect the api documentation to specify what a null return value means, but I could not find explanations for these, so maybe its some general pattern for this SDK?

 

 

0 Kudos
1 Solution

Accepted Solutions
GuntherHeppner
Esri Contributor

Hi @jussih ,

These functions that are suffixed with "OrNull" are lenient functions, following the pattern used in the Kotlin standard library, for example String.toIntOrNull. It means that the function is lenient, i.e. it won't throw an exception if the input is invalid or some other error occurs, instead it returns null. 


Does a null return value mean an error occurred, or that input parameters are invalid somehow?

It could be either. As you point out, the doc should specify that, we are going to make some improvements to that. Thank you for pointing it out.

View solution in original post

0 Kudos
2 Replies
GuntherHeppner
Esri Contributor

Hi @jussih ,

These functions that are suffixed with "OrNull" are lenient functions, following the pattern used in the Kotlin standard library, for example String.toIntOrNull. It means that the function is lenient, i.e. it won't throw an exception if the input is invalid or some other error occurs, instead it returns null. 


Does a null return value mean an error occurred, or that input parameters are invalid somehow?

It could be either. As you point out, the doc should specify that, we are going to make some improvements to that. Thank you for pointing it out.

0 Kudos
jussih
by
New Contributor

Thanks for the reply, makes sense.

I was a bit confused though because I assumed calculations like distance and projection would not fail often. Are there some specific things that can go wrong with the parameters or calculation?

0 Kudos