on master help sign in
Better error throwing
a28394dFang
src/components/old/StatelessTransaction.js+1−1
@@ -185,7 +185,7 @@ class StatelessTransaction extends React.Component {
185 const stx = state.stx.matchWith({
185 const stx = state.stx.matchWith({
186 Just: tx => tx.value,
186 Just: tx => tx.value,
187 Nothing: () => {
187 Nothing: () => {
188− throw BRIDGE_ERROR.MISSING_TXN;
188+ throw new Error(BRIDGE_ERROR.MISSING_TXN);
189 },
189 },
190 });
190 });
191
191
src/lib/error.js+11−11
@@ -1,15 +1,15 @@
1const BRIDGE_ERROR = {
1const BRIDGE_ERROR = {
2− MISSING_WEB3: new Error('no web3 object found'),
2+ MISSING_WEB3: 'no web3 object found',
3− MISSING_WALLET: new Error('no wallet found'),
3+ MISSING_WALLET: 'no wallet found',
4− MISSING_TXN: new Error('no transaction found'),
4+ MISSING_TXN: 'no transaction found',
5− MISSING_CONTRACTS: new Error('no contracts found'),
5+ MISSING_CONTRACTS: 'no contracts found',
6− MISSING_KEYSTORE: new Error('no keystore text found'),
6+ MISSING_KEYSTORE: 'no keystore text found',
7− MISSING_MNEMONIC: new Error('no authentication mnemonic found'),
7+ MISSING_MNEMONIC: 'no authentication mnemonic found',
8− MISSING_URBIT_WALLET: new Error('no urbit wallet found'),
8+ MISSING_URBIT_WALLET: 'no urbit wallet found',
9− MISSING_POINT: new Error('no point found'),
9+ MISSING_POINT: 'no point found',
10− INVALID_ROUTE: new Error('invalid route'),
10+ INVALID_ROUTE: 'invalid route',
11− INVALID_NETWORK_TYPE: new Error('invalid network type'),
11+ INVALID_NETWORK_TYPE: 'invalid network type',
12− INVALID_WALLET_TYPE: new Error('invalid wallet type'),
12+ INVALID_WALLET_TYPE: 'invalid wallet type',
13};
13};
14
14
15const renderTxnError = (web3, msg) => {
15const renderTxnError = (web3, msg) => {
src/lib/keys.js+2−2
@@ -89,7 +89,7 @@ const attemptNetworkSeedDerivation = async (next, args) => {
89 const uwal = urbitWallet.matchWith({
89 const uwal = urbitWallet.matchWith({
90 Just: uw => uw.value,
90 Just: uw => uw.value,
91 Nothing: _ => {
91 Nothing: _ => {
92− throw BRIDGE_ERROR.MISSING_URBIT_WALLET;
92+ throw new Error(BRIDGE_ERROR.MISSING_URBIT_WALLET);
93 },
93 },
94 });
94 });
95
95
@@ -100,7 +100,7 @@ const attemptNetworkSeedDerivation = async (next, args) => {
100 const mnemonic = authMnemonic.matchWith({
100 const mnemonic = authMnemonic.matchWith({
101 Just: mnem => mnem.value,
101 Just: mnem => mnem.value,
102 Nothing: _ => {
102 Nothing: _ => {
103− throw BRIDGE_ERROR.MISSING_MNEMONIC;
103+ throw new Error(BRIDGE_ERROR.MISSING_MNEMONIC);
104 },
104 },
105 });
105 });
106
106
src/lib/need.js+6−6
@@ -19,26 +19,26 @@ export const web3 = needBuilder(() => {
19});
19});
20
20
21export const contracts = needBuilder(() => {
21export const contracts = needBuilder(() => {
22− throw new Error(BRIDGE_ERROR.MISSING_CONTRACTS.message);
22+ throw new Error(BRIDGE_ERROR.MISSING_CONTRACTS);
23});
23});
24
24
25export const wallet = needBuilder(() => {
25export const wallet = needBuilder(() => {
26− throw new Error(BRIDGE_ERROR.MISSING_WALLET.message);
26+ throw new Error(BRIDGE_ERROR.MISSING_WALLET);
27});
27});
28
28
29export const addressFromWallet = obj => wallet(obj).address;
29export const addressFromWallet = obj => wallet(obj).address;
30
30
31export const point = needBuilder(() => {
31export const point = needBuilder(() => {
32− throw new Error(BRIDGE_ERROR.MISSING_POINT.message);
32+ throw new Error(BRIDGE_ERROR.MISSING_POINT);
33});
33});
34
34
35export const pointCache = needBuilder(() => {
35export const pointCache = needBuilder(() => {
36− throw new Error(BRIDGE_ERROR.MISSING_POINT.message);
36+ throw new Error(BRIDGE_ERROR.MISSING_POINT);
37});
37});
38
38
39export const fromPointCache = (cache, point) => {
39export const fromPointCache = (cache, point) => {
40 if (!(point in cache)) {
40 if (!(point in cache)) {
41− throw new Error(BRIDGE_ERROR.MISSING_POINT.message);
41+ throw new Error(BRIDGE_ERROR.MISSING_POINT);
42 }
42 }
43
43
44 return cache[point];
44 return cache[point];
@@ -49,7 +49,7 @@ export const keystore = obj => {
49 return ks.value.matchWith({
49 return ks.value.matchWith({
50 Ok: result => result.value,
50 Ok: result => result.value,
51 Error: _ => {
51 Error: _ => {
52− throw BRIDGE_ERROR.MISSING_KEYSTORE;
52+ throw new Error(BRIDGE_ERROR.MISSING_KEYSTORE);
53 },
53 },
54 });
54 });
55};
55};
src/store/network.js+1−1
@@ -20,7 +20,7 @@ function _useNetwork(initialNetworkType = null) {
20
20
21 const setNetworkType = networkType => {
21 const setNetworkType = networkType => {
22 if (!includes(NETWORK_TYPES, networkType)) {
22 if (!includes(NETWORK_TYPES, networkType)) {
23− throw BRIDGE_ERROR.INVALID_NETWORK_TYPE;
23+ throw new Error(BRIDGE_ERROR.INVALID_NETWORK_TYPE);
24 }
24 }
25 _setNetworkType(networkType);
25 _setNetworkType(networkType);
26 };
26 };
src/store/wallet.js+1−1
@@ -44,7 +44,7 @@ function _useWallet(initialWallet = Nothing(), initialMnemonic = Nothing()) {
44 const setWalletType = useCallback(
44 const setWalletType = useCallback(
45 walletType => {
45 walletType => {
46 if (!includes(WALLET_TYPES, walletType)) {
46 if (!includes(WALLET_TYPES, walletType)) {
47− throw BRIDGE_ERROR.INVALID_WALLET_TYPE;
47+ throw new Error(BRIDGE_ERROR.INVALID_WALLET_TYPE);
48 }
48 }
49
49
50 _setWalletType(walletType);
50 _setWalletType(walletType);
src/views/SentTransaction.js+1−1
@@ -125,7 +125,7 @@ function SentTransaction(props) {
125
125
126 const result = txnCursor.matchWith({
126 const result = txnCursor.matchWith({
127 Nothing: _ => {
127 Nothing: _ => {
128− throw BRIDGE_ERROR.MISSING_TXN;
128+ throw new Error(BRIDGE_ERROR.MISSING_TXN);
129 },
129 },
130 Just: res => res.value,
130 Just: res => res.value,
131 });
131 });