Skip to content

Commit

Permalink
Remove error code casts
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Apr 17, 2024
1 parent 5adc6d0 commit f2deeee
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/lib/api/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Project, ProjectResults, ProjectMembershipList } from "./types";

import { error, type NumericRange } from "@sveltejs/kit";
import { BASE_API_URL } from "@/config/config.js";
import { isErrorCode } from "$lib/utils/isErrorCode";

/**
* Get a single project
Expand All @@ -22,8 +23,8 @@ export async function get(
error(500, { message: e });
});

if (!res.ok) {
error(res.status as NumericRange<400, 599>, {
if (isErrorCode(res.status)) {
error(res.status, {
message: res.statusText,
});
}
Expand Down Expand Up @@ -52,8 +53,8 @@ export async function list(
error(500, { message: e });
});

if (!res.ok) {
error(res.status as NumericRange<400, 599>, {
if (isErrorCode(res.status)) {
error(res.status, {
message: res.statusText,
});
}
Expand Down Expand Up @@ -84,8 +85,8 @@ export async function documents(
error(500, { message: e });
});

if (!res.ok) {
error(res.status as NumericRange<400, 599>, {
if (isErrorCode(res.status)) {
error(res.status, {
message: res.statusText,
});
}
Expand Down

0 comments on commit f2deeee

Please sign in to comment.