mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(devtools): Use the same error message as the signal custom formatter for signal errors
When signals throw errors on read, the devtools will show the same error message as the signal custom formatter. We also don't log errors anymore to the console as those might be surprising to see as errors and are buggy behavior of the devtools.
This commit is contained in:
parent
5b720aa2eb
commit
a0930e166c
2 changed files with 2 additions and 3 deletions
|
|
@ -180,13 +180,13 @@ const getPreview = (propData: TerminalType | CompositeType, isGetterOrSetter: bo
|
|||
if (propData.containerType === 'ReadonlySignal') {
|
||||
const {error, value} = safelyReadSignalValue(propData.prop);
|
||||
if (error) {
|
||||
return 'ERROR: Could not read signal value. See console for details.';
|
||||
return `Signal(⚠️ Error)${error.message ? `: ${error.message}` : ''}`;
|
||||
}
|
||||
return `Readonly Signal(${typeToDescriptorPreview[propData.type](value)})`;
|
||||
} else if (propData.containerType === 'WritableSignal') {
|
||||
const {error, value} = safelyReadSignalValue(propData.prop);
|
||||
if (error) {
|
||||
return 'ERROR: Could not read signal value. See console for details.';
|
||||
return `Signal(⚠️ Error)${error.message ? `: ${error.message}` : ''}`;
|
||||
}
|
||||
return `Signal(${typeToDescriptorPreview[propData.type](value)})`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ export function safelyReadSignalValue(signal: any): {error?: Error; value?: any}
|
|||
const value = signal();
|
||||
return {error: undefined, value};
|
||||
} catch (error) {
|
||||
console.error('[Angular DevTools]: Error reading signal value:', error);
|
||||
return {error: error as Error, value: undefined};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue