Skip to content

Commit

Permalink
feat: enhance error display type
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1030 committed Nov 26, 2024
1 parent 45cbb54 commit c0fcb52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions packages/applet/src/components/state/StateFieldViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,13 @@ async function submitDrafting() {
--at-apply: 'text-#aaa';
}
}
// native error
:deep(.native.Error-state-type) {
--at-apply: 'text-red-500';
&::before {
content: 'Error:';
margin-right: 4px;
}
}
</style>
7 changes: 4 additions & 3 deletions packages/devtools-kit/src/core/component/state/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ function processSetupState(instance: VueAppInstance) {
const value = returnError(() => toRaw(instance.setupState[key])) as unknown as {
render: Function
__asyncLoader: Function

}
const accessError = value instanceof Error

const rawData = raw[key] as {
effect: {
Expand All @@ -151,13 +151,14 @@ function processSetupState(instance: VueAppInstance) {

let result: Partial<InspectorState>

let isOtherType = typeof value === 'function'
let isOtherType = accessError
|| typeof value === 'function'
|| (ensurePropertyExists(value, 'render') && typeof value.render === 'function') // Components
|| (ensurePropertyExists(value, '__asyncLoader') && typeof value.__asyncLoader === 'function') // Components
|| (typeof value === 'object' && value && ('setup' in value || 'props' in value)) // Components
|| /^v[A-Z]/.test(key) // Directives

if (rawData) {
if (rawData && !accessError) {
const info = getSetupStateType(rawData)

const { stateType, stateTypeName } = getStateTypeAndName(info)
Expand Down

0 comments on commit c0fcb52

Please sign in to comment.