Skip to content

Commit

Permalink
Add InvalidAutomergeUrlError
Browse files Browse the repository at this point in the history
  • Loading branch information
neftaly committed Jan 23, 2024
1 parent f4ce137 commit 68e857d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/automerge-repo/src/AutomergeUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,15 @@ export const interpretAsDocumentId = (id: AnyDocumentId) => {
}

// none of the above
throw new Error(`Invalid AutomergeUrl: '${id}'`)
throw new InvalidAutomergeUrlError(`Invalid AutomergeUrl: '${id}'`)
}

export class InvalidAutomergeUrlError extends Error {
constructor(message: string) {
super(message)
// https://github.com/microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work
Object.setPrototypeOf(this, InvalidAutomergeUrlError.prototype)
}
}

// TYPES
Expand Down

0 comments on commit 68e857d

Please sign in to comment.