Skip to content

Commit

Permalink
Throw exception instead of returning null for getDefaultProvider (#351).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Nov 21, 2018
1 parent 98143a8 commit 31d3ee8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src.ts/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ import { ContractFunction, ContractTransaction, Event, EventFilter } from './con
// Helper Functions

function getDefaultProvider(network?: utils.Network | string): providers.BaseProvider {
let n = utils.getNetwork(network || 'homestead');
if (!n || !n._defaultProvider) { return null; }
if (network == null) { network = 'homestead'; }
let n = utils.getNetwork(network);
if (!n || !n._defaultProvider) {
errors.throwError('unsupported getDefaultProvider network', errors.UNSUPPORTED_OPERATION, {
operation: 'getDefaultProvider',
network: network
});
}
return n._defaultProvider(providers);
}

Expand Down

0 comments on commit 31d3ee8

Please sign in to comment.