Skip to content

Commit 82583b5

Browse files
committed
fixing error handling
1 parent dfebf38 commit 82583b5

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/daemon/config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ function migrateConfig (ipfsd) {
167167
config = readConfigFile(ipfsd)
168168
} catch (err) {
169169
// This is a best effort check, dont blow up here, that should happen else where.
170-
// @ts-ignore
171-
logger.error(`[daemon] migrateConfig: error reading config file: ${err.message || err}`)
170+
if (err instanceof Error) {
171+
logger.error(`[daemon] migrateConfig: error reading config file: ${err.message}`)
172+
} else {
173+
logger.error(`[daemon] migrateConfig: error reading config file: ${String(err)}`)
174+
}
172175
return
173176
}
174177

@@ -252,8 +255,11 @@ function migrateConfig (ipfsd) {
252255
writeConfigFile(ipfsd, config)
253256
store.safeSet(REVISION_KEY, REVISION)
254257
} catch (err) {
255-
// @ts-ignore
256-
logger.error(`[daemon] migrateConfig: error writing config file: ${err.message || err}`)
258+
if (err instanceof Error) {
259+
logger.error(`[daemon] migrateConfig: error writing config file: ${err.message}`)
260+
} else {
261+
logger.error(`[daemon] migrateConfig: error writing config file: ${String(err)}`)
262+
}
257263
return
258264
}
259265
}

src/daemon/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ async function setupDaemon () {
5656

5757
ipfsd = res.ipfsd
5858

59-
// @ts-ignore
60-
logger.info(`[daemon] IPFS_PATH: ${ipfsd.path}`)
59+
if (ipfsd) {
60+
logger.info(`[daemon] IPFS_PATH: ${ipfsd.path}`)
61+
} else {
62+
logger.warn('[daemon] IPFS_PATH: ipfsd is undefined')
63+
}
6164
logger.info(`[daemon] PeerID: ${res.id}`)
6265

6366
// Update the path if it was blank previously.

0 commit comments

Comments
 (0)