Closed
Bug 1655112
Opened 6 years ago
Closed 5 years ago
Unintuitive error message when testGetValue does not have a value
Categories
(Data Platform and Tools :: Glean: SDK, defect, P2)
Data Platform and Tools
Glean: SDK
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: mcomella, Assigned: mdroettboom)
Details
Attachments
(2 files)
Example code:
@Test
fun showErrorMessage() {
org.mozilla.fenix.GleanMetrics.StorageStats.appBytes.testGetValue()
}
This will throw an error (full trace attached):
java.lang.NullPointerException
at mozilla.telemetry.glean.private.MemoryDistributionMetricType.testGetValue(MemoryDistributionMetricType.kt:128)
at mozilla.telemetry.glean.private.MemoryDistributionMetricType.testGetValue$default(MemoryDistributionMetricType.kt:123)
...
Usually, a NullPointerException implies programmer error so I interpret this error to mean either:
- I messed up by using a null reference
- There's a bug in a library for that reason
However, the real issue is that there is no value set in StorageStats.appBytes and it requires a little debugging to realize that (I had to look at the glean source to figure it out).
I think it would be more intuitive to do one of, in order of preference:
- throw a custom exception (
GleanTestException?) with a message like, "metric must have value set iftestGetValueis called. SeetestHasValueto check for existence" - throw an IllegalStateException (which is more intuitive than NPE) with a similar message
- Add a similar message to the existing NullPointerException
| Reporter | ||
Comment 1•5 years ago
|
||
This occurred again and prompted me to want to file another issue: https://github.com/mozilla-mobile/fenix/issues/17725#issuecomment-771070137
Updated•5 years ago
|
Priority: -- → P3
Whiteboard: [telemetry:glean-rs:m?]
Updated•5 years ago
|
Priority: P3 → P2
Whiteboard: [telemetry:glean-rs:m?]
| Assignee | ||
Updated•5 years ago
|
Assignee: nobody → mdroettboom
Comment 2•5 years ago
|
||
| Assignee | ||
Updated•5 years ago
|
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•