From ddcf71225226bc0929d5c6d609b13ff0489e5b94 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 14 Aug 2021 22:28:17 +0200 Subject: Revamped backend error handling & improved imports in tests --- packages/server/src/routes/api/v1/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/server/src/routes/api/v1/index.ts') diff --git a/packages/server/src/routes/api/v1/index.ts b/packages/server/src/routes/api/v1/index.ts index 1adb3cb..fa7d8ab 100644 --- a/packages/server/src/routes/api/v1/index.ts +++ b/packages/server/src/routes/api/v1/index.ts @@ -4,7 +4,7 @@ import { Route } from "../../../types/fastify"; import repo from "./repo"; import { verifyRepoName } from "../util"; import { Info as APIInfo, RepositorySummary as APIRepositorySummary, Repository as APIRepository } from "api"; -import { BaseError } from "../../../git/error"; +import { ServerError } from "../../../git/error"; function setHandlers(fastify: FastifyInstance): void { fastify.setErrorHandler((err, req, reply) => { @@ -49,9 +49,9 @@ function reposEndpoints(fastify: FastifyInstance, opts: FastifyPluginOptions, do return; } - const repository: Repository | BaseError = await Repository.open(opts.config.settings.git_dir, req.params.repo).catch(err => err); + const repository = await Repository.open(opts.config.settings.git_dir, req.params.repo).catch((err: ServerError) => err); - if(repository instanceof BaseError) { + if(repository instanceof ServerError) { reply.code(repository.code).send({ error: repository.message }); return; } -- cgit v1.2.3-18-g5258