You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 24, 2023. It is now read-only.
Early in OSHI's development, the code was littered with UnsupportedOperationExceptions. This seems an appropriate response when we're asking for data that simply doesn't exist (e.g., load average on Windows). But it requires the user to explicitly handle these exceptions.
I moved away from exceptions into log messages, which allowed a more finely grained control of what was a normal problem vs. failure (warnings vs. errors etc.) and just returned sensible defaults (negative values, or 0, or empty strings, or empty collections). This introduces the opposite problem, of not allowing the user to handle exception types.
OSHI needs a standardized method of handling these types of situations:
Data is undefined on a platform (Windows load avg.)
Data is not easily obtained on a platform (Windows open files)
Data requires elevated permissions and/or software installs that the user doesn't have (lots of Linux stuff)
Data should normally return but happened to fail in this case (Sensor readings) but the user can try again
Data wasn't updated because you asked for it too recently (tick counts < 1 second apart).
We can use Optional results in key places, or encapsulate the result in our own OshiResult class that includes:
Result object
Result type (similar to how VARIANT is used in JNA)