1- import { Controller , Get } from '@nestjs/common' ;
1+ import { Controller , Get , InternalServerErrorException } from '@nestjs/common' ;
22import { ApiOkResponse , ApiOperation , ApiTags } from '@nestjs/swagger' ;
33import { NetworkConstants } from './entities/constants' ;
44import { Economics } from './entities/economics' ;
55import { NetworkService } from './network.service' ;
66import { Stats } from 'src/endpoints/network/entities/stats' ;
77import { About } from './entities/about' ;
8+ import { OriginLogger } from '@multiversx/sdk-nestjs-common' ;
89
910@Controller ( )
1011@ApiTags ( 'network' )
1112export class NetworkController {
13+ private readonly logger = new OriginLogger ( NetworkController . name ) ;
1214 constructor (
1315 private readonly networkService : NetworkService
1416 ) { }
@@ -31,9 +33,15 @@ export class NetworkController {
3133 @ApiOperation ( { summary : 'Network statistics' , description : 'Returns general network statistics' } )
3234 @ApiOkResponse ( { type : Stats } )
3335 async getStats ( ) : Promise < Stats > {
34- return await this . networkService . getStats ( ) ;
36+ try {
37+ return await this . networkService . getStats ( ) ;
38+ } catch ( error ) {
39+ this . logger . error ( 'Error fetching network stats' , error ) ;
40+ throw new InternalServerErrorException ( 'Failed to fetch network statistics' ) ;
41+ }
3542 }
3643
44+
3745 @Get ( "/about" )
3846 @ApiOperation ( { summary : 'About' , description : 'Returns general information about API deployment' } )
3947 @ApiOkResponse ( { type : About } )
0 commit comments