Handle Promise rejections when importing accounts (#4142)

* Silently catch import failures since errors exist in Redux state
* Add comment about no-op catch statement
feature/default_network_editable
Paul Bouchon 7 years ago committed by GitHub
parent a93237a4cd
commit 5ec631cad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      mascara/src/app/first-time/import-account-screen.js
  2. 2
      old-ui/app/accounts/import/json.js
  3. 2
      old-ui/app/accounts/import/private-key.js
  4. 2
      ui/app/components/pages/create-account/import-account/json.js
  5. 2
      ui/app/components/pages/create-account/import-account/private-key.js

@ -70,10 +70,14 @@ class ImportAccountScreen extends Component {
switch (this.state.selectedOption) { switch (this.state.selectedOption) {
case OPTIONS.JSON_FILE: case OPTIONS.JSON_FILE:
return importNewAccount('JSON File', [ jsonFile, password ]) return importNewAccount('JSON File', [ jsonFile, password ])
// JS runtime requires caught rejections but failures are handled by Redux
.catch()
.then(next) .then(next)
case OPTIONS.PRIVATE_KEY: case OPTIONS.PRIVATE_KEY:
default: default:
return importNewAccount('Private Key', [ privateKey ]) return importNewAccount('Private Key', [ privateKey ])
// JS runtime requires caught rejections but failures are handled by Redux
.catch()
.then(next) .then(next)
} }
} }

@ -96,6 +96,8 @@ class JsonImportSubview extends Component {
} }
this.props.importNewAccount([ fileContents, password ]) this.props.importNewAccount([ fileContents, password ])
// JS runtime requires caught rejections but failures are handled by Redux
.catch()
} }
} }

@ -64,4 +64,6 @@ PrivateKeyImportView.prototype.createNewKeychain = function () {
const input = document.getElementById('private-key-box') const input = document.getElementById('private-key-box')
const privateKey = input.value const privateKey = input.value
this.props.dispatch(actions.importNewAccount('Private Key', [ privateKey ])) this.props.dispatch(actions.importNewAccount('Private Key', [ privateKey ]))
// JS runtime requires caught rejections but failures are handled by Redux
.catch()
} }

@ -105,6 +105,8 @@ class JsonImportSubview extends Component {
} }
this.props.importNewJsonAccount([ fileContents, password ]) this.props.importNewJsonAccount([ fileContents, password ])
// JS runtime requires caught rejections but failures are handled by Redux
.catch()
} }
} }

@ -91,5 +91,7 @@ PrivateKeyImportView.prototype.createNewKeychain = function () {
const { importNewAccount, history } = this.props const { importNewAccount, history } = this.props
importNewAccount('Private Key', [ privateKey ]) importNewAccount('Private Key', [ privateKey ])
// JS runtime requires caught rejections but failures are handled by Redux
.catch()
.then(() => history.push(DEFAULT_ROUTE)) .then(() => history.push(DEFAULT_ROUTE))
} }

Loading…
Cancel
Save