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/repo.ts | |
parent | 81b39ee7848b0fbdcd8b61a04077a58c23580dd1 (diff) |
Revamped backend error handling & improved imports in tests
Diffstat (limited to 'packages/server/src/routes/repo.ts')
-rw-r--r-- | packages/server/src/routes/repo.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/server/src/routes/repo.ts b/packages/server/src/routes/repo.ts index 43d89d2..32ac9c4 100644 --- a/packages/server/src/routes/repo.ts +++ b/packages/server/src/routes/repo.ts @@ -3,7 +3,7 @@ import { CoolFastifyRequest, Route } from "../types/fastify"; import { Tag } from "../git/tag"; import { FastifyInstance, FastifyPluginOptions } from "fastify"; import { verifyRepoName } from "../routes/api/util"; -import { BaseError } from "../git/error"; +import { ServerError } from "../git/error"; export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, done: (err?: Error) => void): void { fastify.addHook("onRequest", async(req: CoolFastifyRequest, reply) => { @@ -62,16 +62,16 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do method: "GET", url: "/refs/tags/:tag", handler: async(req, reply) => { - const repository = await Repository.open(opts.config.settings.git_dir, req.params.repo).catch((err: BaseError) => 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(repository.message); return; } - const tag = await Tag.lookup(repository, req.params.tag).catch((err: BaseError) => err); + const tag = await Tag.lookup(repository, req.params.tag).catch((err: ServerError) => err); - if(tag instanceof BaseError) { + if(tag instanceof ServerError) { reply.code(tag.code).send(tag.message); return; } |