Skip to content

Commit 53b3786

Browse files
committed
don't throw unhelpful when passed a bad URL
1 parent 9c31e38 commit 53b3786

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/useDocHandle.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ export default function useDocHandle<T>(
3838
if (options?.["~skipInitialValue"]) return undefined
3939
const unwrappedURL = access(url)
4040
if (!unwrappedURL) return undefined
41-
const parsedURL = parseAutomergeUrl(unwrappedURL)
42-
const existingHandle = repo.handles[parsedURL.documentId]
43-
if (existingHandle?.isReady()) {
44-
return existingHandle as DocHandle<T>
41+
try {
42+
const parsedURL = parseAutomergeUrl(unwrappedURL)
43+
const existingHandle = repo.handles[parsedURL.documentId]
44+
if (existingHandle?.isReady()) {
45+
return existingHandle as DocHandle<T>
46+
}
47+
} catch (error) {
48+
console.error("Error parsing URL:", error)
4549
}
4650
}
4751

0 commit comments

Comments
 (0)