Skip to content

Commit b8ae1cc

Browse files
authored
Merge pull request #724 from Adamant-im/feat/update-sending-texts
feat: add NoInternetConnectionError error
2 parents 6a8ed1f + 22ba210 commit b8ae1cc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/components/SendFundsForm.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
<script>
190190
import { adm } from '@/lib/nodes'
191191
import klyIndexer from '@/lib/nodes/kly-indexer'
192-
import { AllNodesDisabledError, AllNodesOfflineError } from '@/lib/nodes/utils/errors'
192+
import { AllNodesDisabledError, AllNodesOfflineError, NoInternetConnectionError } from '@/lib/nodes/utils/errors'
193193
import { PendingTransactionError } from '@/lib/pending-transactions'
194194
import axios from 'axios'
195195
import { nextTick } from 'vue'
@@ -791,6 +791,8 @@ export default {
791791
message = this.$t('transfer.error_pending_transaction', {
792792
crypto: error.crypto
793793
})
794+
} else if (error instanceof NoInternetConnectionError) {
795+
message = this.$t('connection.offline')
794796
}
795797
this.$emit('error', message)
796798
})
@@ -801,6 +803,10 @@ export default {
801803
})
802804
},
803805
async sendFunds() {
806+
if (!navigator.onLine) {
807+
throw new NoInternetConnectionError()
808+
}
809+
804810
if (this.currency === Cryptos.ADM) {
805811
let promise
806812
// 1. if come from Chat then sendMessage

src/lib/nodes/utils/errors.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ export class AllNodesDisabledError extends Error {
6363
export function isAllNodesDisabledError(error: Error): error is AllNodesDisabledError {
6464
return (error as AllNodesDisabledError).code === CODES.ALL_NODES_DISABLED
6565
}
66+
67+
export class NoInternetConnectionError extends Error {
68+
constructor() {
69+
super();
70+
}
71+
}

0 commit comments

Comments
 (0)