Skip to content

Commit

Permalink
fix(core): do not throw if schemaType is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Jan 3, 2025
1 parent 5ff3aae commit ae63a80
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import {isValidationErrorMarker, type SanityDocument, type Schema} from '@sanity/types'
import {
isValidationErrorMarker,
type PreviewValue,
type SanityDocument,
type Schema,
} from '@sanity/types'
import {uuid} from '@sanity/uuid'
import {useMemo} from 'react'
import {useObservable} from 'react-rx'
Expand Down Expand Up @@ -108,7 +113,18 @@ const getActiveReleaseDocumentsObservable = ({
map((document) => {
const schemaType = schema.get(document._type)
if (!schemaType) {
throw new Error(`Schema type not found for document type ${document._type}`)
console.error(
`Schema type not found for document type ${document._type} (document ID: ${document._id})`,
)
return of({
isLoading: false,
values: {
_id: document._id,
title: `Document type "${document._type}" not found`,
_createdAt: document._createdAt,
_updatedAt: document._updatedAt,
} satisfies PreviewValue,
})
}

return documentPreviewStore.observeForPreview(document, schemaType).pipe(
Expand Down

0 comments on commit ae63a80

Please sign in to comment.