mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
feat: enhance error log
This commit is contained in:
parent
1514c3e7fe
commit
baa41b3084
3 changed files with 10 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import * as Sentry from '@sentry/browser'
|
||||
import { Middleware } from 'driver/connect.js'
|
||||
import { IN_PRODUCTION_MODE } from 'env'
|
||||
import * as Sentry from '@sentry/browser'
|
||||
import { version } from '../package.json'
|
||||
|
||||
const PUBLIC_KEY = 'd22ec5c9cc874539a51c78388c12e3b0'
|
||||
|
|
@ -29,7 +29,12 @@ export const withErrorLog: Middleware = function withErrorLog(method, args) {
|
|||
]
|
||||
}
|
||||
|
||||
function reportError(error: Error, extra?: any) {
|
||||
function reportError(
|
||||
error: Error,
|
||||
extra?: {
|
||||
[key: string]: any
|
||||
},
|
||||
) {
|
||||
if (!IN_PRODUCTION_MODE) {
|
||||
console.error(error)
|
||||
console.error('Extra:\n', extra)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ function handleParsed(root: TreeNode, parsed: Parsed) {
|
|||
node.accessDenied = true
|
||||
}
|
||||
} else {
|
||||
raiseError(Error(`Sub-module node ${path} not found`))
|
||||
raiseError(new Error(`Sub-module node not found`), { path })
|
||||
}
|
||||
} else {
|
||||
handleParsed(root, value as Parsed)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ function isEmptyProject(content: any /* examined any */) {
|
|||
}
|
||||
|
||||
function isBlockedProject(content: any /* examined any */) {
|
||||
return content && content['message'] === "Repository access blocked"
|
||||
return content && content['message'] === 'Repository access blocked'
|
||||
}
|
||||
|
||||
type Options = {
|
||||
|
|
@ -45,7 +45,7 @@ async function request(url: string, { accessToken }: Options = {}) {
|
|||
if (isEmptyProject(content)) throw new Error(EMPTY_PROJECT)
|
||||
if (isBlockedProject(content)) throw new Error(BLOCKED_PROJECT)
|
||||
// Unknown type of error, report it!
|
||||
raiseError(new Error(`Got ${res.statusText} when requesting ${url}`))
|
||||
raiseError(new Error(res.statusText))
|
||||
throw new Error(content && content.message)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue