From 31d3ee899f4331cb75952eceb07b9a8ad7b30e9f Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Wed, 21 Nov 2018 16:23:44 -0500 Subject: [PATCH] Throw exception instead of returning null for getDefaultProvider (#351). --- src.ts/ethers.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src.ts/ethers.ts b/src.ts/ethers.ts index 6fe361e7..5a750638 100644 --- a/src.ts/ethers.ts +++ b/src.ts/ethers.ts @@ -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); }