mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-07-08 19:15:09 +00:00
Fixed some error logging
This commit is contained in:
@@ -5,6 +5,7 @@ import { Dirent, readdir as _readdir } from 'fs'
|
||||
import { promisify } from 'util'
|
||||
import { join } from 'path'
|
||||
import { devLog } from '../shared/ElectronUtilFunctions'
|
||||
import { serializeError } from 'serialize-error'
|
||||
|
||||
const readdir = promisify(_readdir)
|
||||
const rimraf = promisify(_rimraf)
|
||||
@@ -32,7 +33,7 @@ class ClearCacheHandler implements IPCInvokeHandler<'clear-cache'> {
|
||||
devLog(`Deleting ${file.isFile() ? 'file' : 'folder'}: ${join(tempPath, file.name)}`)
|
||||
await rimraf(join(tempPath, file.name))
|
||||
} catch (err) {
|
||||
devLog(`Failed to delete ${file.isFile() ? 'file' : 'folder'}: `, err)
|
||||
devLog(`Failed to delete ${file.isFile() ? 'file' : 'folder'}: `, serializeError(err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import Bottleneck from 'bottleneck'
|
||||
import { promisify } from 'util'
|
||||
import { join } from 'path'
|
||||
import { tempPath } from '../../shared/Paths'
|
||||
import { serializeError } from 'serialize-error'
|
||||
const drive = google.drive('v3')
|
||||
const limiter = new Bottleneck({
|
||||
minTime: 200 // Wait 200 ms between API requests
|
||||
@@ -120,7 +121,7 @@ class APIFileDownloader {
|
||||
if (this.wasCanceled) { return }
|
||||
this.startDownloadStream()
|
||||
} else {
|
||||
devLog(err)
|
||||
devLog(serializeError(err))
|
||||
if (err?.code && err?.response?.statusText) {
|
||||
this.failDownload(downloadErrors.responseError(`${err.code} (${err.response.statusText})`))
|
||||
} else {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { serverURL } from '../../shared/Paths'
|
||||
import * as fs from 'fs'
|
||||
import { promisify } from 'util'
|
||||
import { devLog } from '../../shared/ElectronUtilFunctions'
|
||||
import { serializeError } from 'serialize-error'
|
||||
|
||||
const unlink = promisify(fs.unlink)
|
||||
|
||||
@@ -100,7 +101,7 @@ export class GoogleAuth {
|
||||
|
||||
authServer.on('authCode', async (authCode) => {
|
||||
this.token = (await this.oAuth2Client.getToken(authCode)).tokens
|
||||
writeFile(TOKEN_PATH, this.token).catch(err => devLog('Got token, but failed to write it to TOKEN_PATH:', err))
|
||||
writeFile(TOKEN_PATH, this.token).catch(err => devLog('Got token, but failed to write it to TOKEN_PATH:', serializeError(err)))
|
||||
|
||||
this.authenticateWithToken()
|
||||
|
||||
@@ -134,7 +135,7 @@ export class GoogleAuth {
|
||||
'get',
|
||||
serverURL + `/api/data/client`, null, (err, response) => {
|
||||
if (err) {
|
||||
devLog('Could not authenticate because client info could not be retrieved from the server:', err)
|
||||
devLog('Could not authenticate because client info could not be retrieved from the server:', serializeError(err))
|
||||
resolve(false)
|
||||
} else {
|
||||
this.oAuth2Client = new google.auth.OAuth2(response.body.CLIENT_ID, response.body.CLIENT_SECRET, REDIRECT_URI)
|
||||
@@ -180,7 +181,7 @@ export class GoogleAuth {
|
||||
try {
|
||||
await unlink(TOKEN_PATH)
|
||||
} catch (err) {
|
||||
devLog('Failed to delete token:', err)
|
||||
devLog('Failed to delete token:', serializeError(err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ export function hasVideoExtension(name: string) {
|
||||
|
||||
/**
|
||||
* Log a message in the main BrowserWindow's console.
|
||||
* Note: Error objects can't be serialized by this; use serializeError(err) before passing it here.
|
||||
*/
|
||||
export function devLog(...messages: any[]) {
|
||||
emitIPCEvent('log', messages)
|
||||
|
||||
Reference in New Issue
Block a user