diff --git a/packages/scenes/src/variables/components/VariableValueSelectors.tsx b/packages/scenes/src/variables/components/VariableValueSelectors.tsx index 22838d854..305ccd2f3 100644 --- a/packages/scenes/src/variables/components/VariableValueSelectors.tsx +++ b/packages/scenes/src/variables/components/VariableValueSelectors.tsx @@ -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} /> diff --git a/packages/scenes/src/variables/sets/SceneVariableSet.test.tsx b/packages/scenes/src/variables/sets/SceneVariableSet.test.tsx index 29d5da027..a5a582030 100644 --- a/packages/scenes/src/variables/sets/SceneVariableSet.test.tsx +++ b/packages/scenes/src/variables/sets/SceneVariableSet.test.tsx @@ -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', () => { @@ -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({ @@ -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); @@ -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); diff --git a/packages/scenes/src/variables/sets/SceneVariableSet.ts b/packages/scenes/src/variables/sets/SceneVariableSet.ts index b95efb7f7..aed845499 100644 --- a/packages/scenes/src/variables/sets/SceneVariableSet.ts +++ b/packages/scenes/src/variables/sets/SceneVariableSet.ts @@ -247,7 +247,7 @@ export class SceneVariableSet extends SceneObjectBase 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);