Skip to content

Commit d6f12db

Browse files
fix: improved error handling
1 parent a709618 commit d6f12db

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/api/v2/git.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Debug from 'debug'
22
import { Response } from 'express'
3-
import { BadRequestError } from 'src/error'
4-
import { lockApi } from 'src/middleware/session'
3+
import { lockApi } from 'src/middleware'
54
import { OpenApiRequestExt } from 'src/otomi-models'
65

76
const debug = Debug('otomi:api:v2:git')
@@ -30,7 +29,9 @@ export const migrateGit = async (req: OpenApiRequestExt, res: Response): Promise
3029
try {
3130
remoteHasContent = await req.otomi.git.testRemoteConnection(repoUrl, password, branch, username)
3231
} catch (e: any) {
33-
throw new BadRequestError(`Cannot connect to new git remote: ${e.message}`)
32+
const error = { message: `Cannot connect to new git remote: ${e.message}`, statusCode: 404 }
33+
res.json(error)
34+
return
3435
}
3536

3637
// Write config + commit locally → push to new remote (if empty) → push to current remote

0 commit comments

Comments
 (0)