Skip to content

Commit

Permalink
fix faulty null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed Feb 12, 2020
1 parent 702e342 commit 764832d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
* @returns {EthereumRpcError} The error
*/
server: (opts) => {
if (typeof opts !== 'object' || Array.isArray(opts)) {
if (!opts || typeof opts !== 'object' || Array.isArray(opts)) {
throw new Error('Ethereum RPC Server errors must provide single object argument.')
}
const { code } = opts
Expand Down Expand Up @@ -203,7 +203,7 @@ module.exports = {
* @returns {EthereumProviderError} The error
*/
custom: (opts) => {
if (typeof opts !== 'object' || Array.isArray(opts)) {
if (!opts || typeof opts !== 'object' || Array.isArray(opts)) {
throw new Error('Ethereum Provider custom errors must provide single object argument.')
}
const { code, message, data } = opts
Expand Down Expand Up @@ -240,7 +240,7 @@ function validateOpts (opts) {
if (opts) {
if (typeof opts === 'string') {
message = opts
} else if (opts && typeof opts === 'object' && !Array.isArray(opts)) {
} else if (typeof opts === 'object' && !Array.isArray(opts)) {
message = opts.message
data = opts.data
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function serializeError (error, fallbackError = FALLBACK_ERROR) {
)
}

if (typeof error === 'object' && error instanceof EthereumRpcError) {
if (error instanceof EthereumRpcError) {
return error.serialize()
}

Expand Down

0 comments on commit 764832d

Please sign in to comment.