terriajs
terriajs copied to clipboard
[EPIC] Error handling
On master
we handle errors through terria.error
Cesium event showing a dialogue for each error. Since the preview map has it's own Terria
it can handle preview-related errors and just change the caption text.
We need to redesign this. One option is for each catalog item to have it's own event where errors are sent to. The workbench would then listen to catalog items that are on the bench, and the preview map listen to those on the preview map. What about loading groups in the catalogue or querying metadata from a WMS?
Perhaps also various levels of verbosity/notify-user-ness, & put the useful-to-know-but-don't-show-it-in-my-face into a "( ! )" kind of icon somewhere that opens up maybe?
We should just use this...
type Value<T> = T & {__warning__?: string}
A proposal put through is to start a "bucket of errors" property on the terria
mobx model and start putting things in there to get us started
Investigate why the following gives no errors:
{
"name": "A",
"type": "my-type",
...,
"featureInfoTemplate": {
"template": "a feature {{feat_name}}.\n{{desc}}",
"partial": {
"desc": "This is a {{feat_type}}"
}
}
}
The misspelling of partials
as partial
results in none of the featureInfoTemplate
traits are present.
I have had a similar experience with other objectTraits
- for example - CSV trait polling
Also, it would be nice to get type errors for mismatched type property:
@primitiveTrait({
type: "string",
name: "Allow undefined",
description: "Allow dimension to be undefined"
})
allowUndefined?: boolean;
Also there are times where Terria will white-screen because of trait issues (like that one above) - and it is nearly impossible to see where the error occurred. It would be nice if we had a really loud error message for trait issues
If you have an incorrect trait (for example opacity
as a string) it will ignore ALL traits after opacity
and not give you a warning
eg
{
"homeCamera": {
"north": -8,
"east": 158,
"south": -45,
"west": 109
},
"catalog": [
{
"type": "wms",
"id": "deacoast",
"name": "Digital Earth Australia Coastlines",
"url": "https://geoserver.dea.ga.gov.au/geoserver/wms",
"opacity": "1.0",
"layers": "dea:DEACoastLines"
}
],
"workbench": [
"deacoast"
]
}
will not add layers
property
Meeting notes 22/02/2021:
- Straight migration from v7 to v8 poses some challenges, such as throwing an error from a pure function (linked to the implicit assumption that the data is correct and able to compute)
- to avoid throwing errors/warnings from inside a pure function, when something is off but is a guess, you can:
- do data validation beforehand
- use Sentinel values or fp-ts
- re-writing the traits system is very complex and it should be avoided, especially if it involves modifying MobX
- other options could include the use of a global status tree - to have an "error" property to maintain irrespective of how the error is triggered
Steps (in priority order):
- In v8, handle the easy cases first: e.g. tile error handling; error boundaries in REACT code
- upsert model from JSON
- review the current error handling implementation in v7 to understand the overall problem we're trying to solve, especially from an end user perspective. Ana & Phil will need a list of current errors and how they are generated. Examples: when do we throw an error - check the translation.json - search in title log message
- Investigate and activate/configure Rollbars in current apps (following the review of errors done at step 3).
To support "warnings" & errors everywhere in the Traits system we could use a type system like:
class PartialError<T> extends TerriaError {
partialResult: T;
}
// inside a Traits class
{
layers: string | undefined | TerriaError;
}
And create helper functions to deal with those (following fp-ts
-like principles).
Next steps:
- Step 1 - error messages for end users (non developers) - curate the message with clear instructions (@AnaBelgun @phil); investigating toast option vs blocking step on landing page
- https://github.com/TerriaJS/terriajs/pull/5454
- Step 2 - error boundaries @steve9164
- [x] https://github.com/TerriaJS/terriajs/issues/5627
- [ ] https://github.com/TerriaJS/terriajs/issues/6007
- [ ] https://github.com/TerriaJS/terriajs/issues/6567