Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SceneVariableSet: Store the whole error object instead of the error message #972

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function VariableLabel({ variable, layout, hideLabel }: VariableSelectProps) {
isLoading={state.loading}
onCancel={() => variable.onCancel?.()}
label={labelOrName}
error={state.error}
error={state.error?.message || state.error}
layout={layout}
description={state.description ?? undefined}
/>
Expand Down
12 changes: 6 additions & 6 deletions packages/scenes/src/variables/sets/SceneVariableSet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ describe('SceneVariableList', () => {

scene.activate();

expect(A.state.error).toBe('Danger!');
expect(A.state.error).toStrictEqual(new Error('Danger!'));
});

it('Should complete updating chained variables in case of error in all variables', () => {
Expand Down Expand Up @@ -665,11 +665,11 @@ describe('SceneVariableList', () => {
scene.activate();

expect(A.state.loading).toBe(false);
expect(A.state.error).toBe('Error in A');
expect(A.state.error).toStrictEqual(new Error('Error in A'));
expect(B.state.loading).toBe(false);
expect(B.state.error).toBe('Error in B');
expect(B.state.error).toStrictEqual(new Error('Error in B'));
expect(C.state.loading).toBe(false);
expect(C.state.error).toBe('Error in C');
expect(C.state.error).toStrictEqual(new Error('Error in C'));
});
it('Should complete updating chained variables in case of error in the first variable', () => {
const A = new TestVariable({
Expand Down Expand Up @@ -702,7 +702,7 @@ describe('SceneVariableList', () => {
scene.activate();

expect(A.state.loading).toBe(false);
expect(A.state.error).toBe('Error in A');
expect(A.state.error).toStrictEqual(new Error('Error in A'));

B.signalUpdateCompleted();
expect(B.state.loading).toBe(false);
Expand Down Expand Up @@ -750,7 +750,7 @@ describe('SceneVariableList', () => {

expect(B.state.loading).toBe(false);
expect(B.state.value).toBe('');
expect(B.state.error).toBe('Error in B');
expect(B.state.error).toStrictEqual(new Error('Error in B'));

C.signalUpdateCompleted();
expect(C.state.loading).toBe(false);
Expand Down
2 changes: 1 addition & 1 deletion packages/scenes/src/variables/sets/SceneVariableSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export class SceneVariableSet extends SceneObjectBase<SceneVariableSetState> imp
this._updating.delete(variable);
this._variablesToUpdate.delete(variable);

variable.setState({ loading: false, error: err.message });
variable.setState({ loading: false, error: err });

console.error('SceneVariableSet updateAndValidate error', err);

Expand Down