1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

migrator - dont overwrite error stack and warn to console

This commit is contained in:
kumavis 2018-04-05 13:38:34 -07:00
parent 7fdf663ea7
commit ffc71ff7d2

View File

@ -29,9 +29,12 @@ class Migrator extends EventEmitter {
// accept the migration as good
versionedData = migratedData
} catch (err) {
// rewrite error message to add context without clobbering stack
const originalErrorMessage = err.message
err.message = `MetaMask Migration Error #${migration.version}: ${originalErrorMessage}`
console.warn(err.stack)
// emit error instead of throw so as to not break the run (gracefully fail)
const error = new Error(`MetaMask Migration Error #${migration.version}:\n${err.stack}`)
this.emit('error', error)
this.emit('error', err)
// stop migrating and use state as is
return versionedData
}