Skip to content

Commit a365937

Browse files
committed
use HttpErrorInterceptor instead of ErrorHandler
1 parent 8e15322 commit a365937

File tree

14 files changed

+47
-50
lines changed

14 files changed

+47
-50
lines changed

packages/insight-previous/src/app/app.module.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { HttpClientModule } from '@angular/common/http';
2-
import { ErrorHandler, NgModule } from '@angular/core';
1+
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
2+
import { NgModule } from '@angular/core';
33
import { BrowserModule } from '@angular/platform-browser';
44
import { IonicApp, IonicModule } from 'ionic-angular';
55
import { BlocksPage, HomePage, PagesModule } from '../pages';
@@ -8,7 +8,7 @@ import { ApiProvider } from '../providers/api/api';
88
import { BlocksProvider } from '../providers/blocks/blocks';
99
import { CurrencyProvider } from '../providers/currency/currency';
1010
import { DefaultProvider } from '../providers/default/default';
11-
import { ErrorsHandler } from '../providers/error-handler/error-handler';
11+
import { HttpErrorInterceptor } from '../providers/error-handler/error-handler';
1212
import { Logger } from '../providers/logger/logger';
1313
import { PriceProvider } from '../providers/price/price';
1414
import { RedirProvider } from '../providers/redir/redir';
@@ -31,8 +31,9 @@ import { InsightApp } from './app.component';
3131
entryComponents: [InsightApp, HomePage, BlocksPage],
3232
providers: [
3333
{
34-
provide: ErrorHandler,
35-
useClass: ErrorsHandler
34+
provide: HTTP_INTERCEPTORS,
35+
useClass: HttpErrorInterceptor,
36+
multi: true
3637
},
3738
ApiProvider,
3839
CurrencyProvider,

packages/insight-previous/src/components/coin-list/coin-list.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class CoinListComponent implements OnInit {
2727
private addrProvider: AddressProvider,
2828
private txsProvider: TxsProvider,
2929
private events: Events
30-
) { }
30+
) {}
3131

3232
public ngOnInit(): void {
3333
if (this.txs && this.txs.length === 0) {
@@ -40,10 +40,9 @@ export class CoinListComponent implements OnInit {
4040
this.loading = false;
4141
this.events.publish('CoinList', { length: data.length });
4242
},
43-
err => {
43+
() => {
4444
this.loading = false;
4545
this.showTransactions = false;
46-
throw err;
4746
}
4847
);
4948
}

packages/insight-previous/src/components/head-nav/head-nav.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class HeadNavComponent implements OnInit {
4646
private navCtrl: NavController,
4747
private logger: Logger,
4848
private apiProvider: ApiProvider
49-
) { }
49+
) {}
5050

5151
public ngOnInit(): void {
5252
this.params = {

packages/insight-previous/src/components/latest-blocks/latest-blocks.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
6565
err => {
6666
this.subscriber.unsubscribe();
6767
clearInterval(this.reloadInterval);
68-
this.errorMessage = err.message;
68+
this.errorMessage = err;
6969
this.loading = false;
70-
throw err;
7170
}
7271
);
7372
}
@@ -90,7 +89,6 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
9089
err => {
9190
this.errorMessage = err.message;
9291
this.loading = false;
93-
throw err;
9492
}
9593
);
9694
}

packages/insight-previous/src/components/latest-transactions/latest-transactions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ export class LatestTransactionsComponent implements OnChanges {
4848
this.transactions = JSON.parse(data._body);
4949
this.loading = false;
5050
},
51-
err => {
51+
() => {
5252
this.loading = false;
53-
throw err;
5453
}
5554
);
5655
}

packages/insight-previous/src/components/transaction-list/transaction-list.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export class TransactionListComponent implements OnInit {
2121
public limit = 10;
2222
public chunkSize = 100;
2323

24-
constructor(
25-
private txProvider: TxsProvider
26-
) { }
24+
constructor(private txProvider: TxsProvider) {}
2725

2826
public ngOnInit(): void {
2927
if (this.transactions && this.transactions.length === 0) {
@@ -39,9 +37,8 @@ export class TransactionListComponent implements OnInit {
3937
this.transactions = sortedTxs;
4038
this.loading = false;
4139
},
42-
err => {
40+
() => {
4341
this.loading = false;
44-
throw err;
4542
}
4643
);
4744
} else {

packages/insight-previous/src/pages/address/address.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ export class AddressPage {
6666
this.loading = false;
6767
},
6868
err => {
69-
this.errorMessage = err.message;
69+
this.errorMessage = err;
7070
this.loading = false;
71-
throw err;
7271
}
7372
);
7473
}

packages/insight-previous/src/pages/block-detail/block-detail.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ export class BlockDetailPage {
6161
this.loading = false;
6262
},
6363
err => {
64-
this.errorMessage = err.message;
64+
this.errorMessage = err;
6565
this.loading = false;
66-
throw err;
6766
}
6867
);
6968
}

packages/insight-previous/src/pages/blocks/blocks.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ export class BlocksPage {
4343
this.blocks = blocks;
4444
this.loading = false;
4545
},
46-
err => {
46+
() => {
4747
this.loading = false;
48-
throw err;
4948
}
5049
);
5150
}

packages/insight-previous/src/pages/broadcast-tx/broadcast-tx.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ export class BroadcastTxPage {
6363
this.presentToast(true, response);
6464
},
6565
err => {
66-
this.presentToast(false, err.message);
67-
throw err;
66+
this.presentToast(false, err);
6867
}
6968
);
7069
}

0 commit comments

Comments
 (0)