Skip to content

Commit f27de98

Browse files
authored
fix: fix usage of custom errors (#1287)
* fix ExhaustivenessError usage * fix InvalidInviteError usage * fix IconNotFoundError usage * fix KeyNotFoundError usage * fix BlobReadError usage * fix FailedToGetStyleError usage * fix InvalidProjectJoinDetailsError usage * fix RoleAssignError usage * update InvalidMapShareError usage * Revert "fix InvalidInviteError usage" This reverts commit a238f3e. * Revert "fix InvalidProjectJoinDetailsError usage" This reverts commit 0fd786b. * Revert "fix RoleAssignError usage" This reverts commit 3fd007e. * Revert "update InvalidMapShareError usage" This reverts commit c4a1ec4.
1 parent 34f273f commit f27de98

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/blob-api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class BlobApi {
6262
const writePromises = [
6363
pipeline(fs.createReadStream(original), hashTransform(hash), ws).catch(
6464
(/** @type {Error} */ e) => {
65-
throw new BlobReadError(original, { cause: e })
65+
throw new BlobReadError({ path: original }, { cause: e })
6666
}
6767
),
6868
]
@@ -76,7 +76,7 @@ export class BlobApi {
7676
writePromises.push(
7777
pipeline(fs.createReadStream(preview), ws).catch(
7878
(/** @type {Error} */ e) => {
79-
throw new BlobReadError(preview, { cause: e })
79+
throw new BlobReadError({ path: preview }, { cause: e })
8080
}
8181
)
8282
)
@@ -91,7 +91,7 @@ export class BlobApi {
9191
writePromises.push(
9292
pipeline(fs.createReadStream(thumbnail), ws).catch(
9393
(/** @type {Error} */ e) => {
94-
throw new BlobReadError(thumbnail, { cause: e })
94+
throw new BlobReadError({ path: thumbnail }, { cause: e })
9595
}
9696
)
9797
)

src/fastify-plugins/maps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function plugin(fastify, opts) {
4949
}
5050

5151
if (!response.ok) {
52-
throw new FailedToGetStyleError(customStyleJsonUrl)
52+
throw new FailedToGetStyleError({ href: customStyleJsonUrl })
5353
}
5454

5555
/** @type {Stats | undefined} */

src/import-categories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export async function importCategories(project, { filePath, logger }) {
7676
const iconXml = await reader.getIcon(iconName)
7777
if (!iconXml) {
7878
// This should never happen because of the validate() call above
79-
throw new IconNotFoundError(iconName)
79+
throw new IconNotFoundError({ iconName })
8080
}
8181
/** @type {Parameters<typeof project.$icons.create>[0]} */
8282
const icon = {
@@ -360,7 +360,7 @@ function appliesToToGeometry(appliesTo) {
360360
function getOrThrow(map, key) {
361361
if (!(map instanceof Map)) throw new TypeError('map must be a Map')
362362
if (!map.has(key)) {
363-
throw new KeyNotFoundError(key)
363+
throw new KeyNotFoundError({ key })
364364
}
365365
return /** @type {V} */ (map.get(key))
366366
}

src/local-peers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ export class LocalPeers extends TypedEmitter {
872872
}
873873
/* c8 ignore next 2 */
874874
default:
875-
throw new ExhaustivenessError(type)
875+
throw new ExhaustivenessError({ value: type })
876876
}
877877
}
878878

0 commit comments

Comments
 (0)