diff options
author | HampusM <hampus@hampusmat.com> | 2021-08-14 22:28:17 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-08-14 22:28:17 +0200 |
commit | ddcf71225226bc0929d5c6d609b13ff0489e5b94 (patch) | |
tree | 7f788d29af4441e27d709aaec1359e205871a11b /packages/server/src/routes/api/v1/index.ts | |
parent | 81b39ee7848b0fbdcd8b61a04077a58c23580dd1 (diff) |
Revamped backend error handling & improved imports in tests
Diffstat (limited to 'packages/server/src/routes/api/v1/index.ts')
-rw-r--r-- | packages/server/src/routes/api/v1/index.ts | 6 |
1 files changed, 3 insertions, 3 deletions
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; } |