Handle external-state plugin errors with ErrorController#868
Conversation
Bundle ReportChanges will increase total bundle size by 382.95kB (8.0%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: plugins/async-node/coreAssets Changed:
view changes for bundle: plugins/beacon/coreAssets Changed:
view changes for bundle: plugins/asset-transform/coreAssets Changed:
view changes for bundle: core/playerAssets Changed:
view changes for bundle: plugins/external-state/coreAssets Changed:
view changes for bundle: plugins/reference-assets/coreAssets Changed:
view changes for bundle: plugins/markdown/coreAssets Changed:
view changes for bundle: plugins/metrics/coreAssets Changed:
view changes for bundle: plugins/check-path/coreAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## player-1-dot-zero #868 +/- ##
========================================
========================================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| test("no handler registered for external state - no transition occurs", async () => { | ||
| // Create a player with NO handlers registered | ||
| test("no handler registered for external state - calls captureError with ExternalStateError", async () => { |
There was a problem hiding this comment.
Can we get some tests to validate how you'd handle this error by the error controller? My understanding is there are two ways, one via content and another by tapping onError. I think these tests would be valid for each platform, at least the onError ones since external actions are closer to integrations.
| this.errorController?.captureError( | ||
| ExternalStateError.missingTransitionValue(toState.value.ref), | ||
| ); | ||
| return; |
There was a problem hiding this comment.
How should the error be handled if we there isn't an errorController? Right now it'd fail silently potentially leaving the user stuck with a blank or stale screen. It'd likely be worth logging up front so that integrators know when this happens, or maybe a check at the start to ensure we have what we need to continue, like the InProgress state check below.
| extends Error | ||
| implements PlayerErrorMetadata<ExternalStateErrorMetadata> | ||
| { | ||
| readonly type: string = "EXTERNAL-STATE"; |
There was a problem hiding this comment.
Can we follow the same convention for types as the primary type definition, i.e. lowercase?
| extends Error | ||
| implements PlayerErrorMetadata<ExternalStateErrorMetadata> | ||
| { | ||
| readonly type: string = "externalState"; |
There was a problem hiding this comment.
May we add this to ErrorTypes so it's the single source of truth. for example: export const ErrorTypes = {
EXTERNAL_STATE: "externalState",
}
Drop the : string annotation: readonly type = ErrorTypes.EXTERNAL_STATE. Since ErrorTypes is as const, the field infers the literal "external-state". Because string widens it and breaks narrowing — TS can't tell this error apart from others whose type is also typed as string.
There was a problem hiding this comment.
Er, except I probably will keep string since that's the pattern used in other places.
3f7a804 to
3a9f697
Compare
| @TestTemplate | ||
| fun testMissingHandlerNavigatesViaContentErrorTransitions() = runBlockingTest { | ||
| val plugin = ExternalStatePlugin( | ||
| ExternalStateHandler(ref = "different-ref") { _, _, transition -> |
There was a problem hiding this comment.
hmmmm is having no handler expected to go into an error state? Do we not get a bunch of no-ops if there's no handler found for the ref in the registry? Could you show me where it errors out
There was a problem hiding this comment.
Hi! It goes into an error state, yeah. Here is where the core code errors out.
Now that
ErrorControlleris available, we use that to handle errors from theexternal-stateplugin instead of letting it fall through. See included docs updates for more details.Change Type (required)
Indicate the type of change your pull request is:
patchminormajorN/A. Part of 1.0Does your PR have any documentation updates?