@@ -12,26 +12,31 @@ import { trackMCPEvent, trackMCPFailure } from "../lib/instrumentation";
12
12
export async function getNetworkFailures ( args : {
13
13
sessionId : string ;
14
14
} ) : Promise < CallToolResult > {
15
- const failureLogs = await retrieveNetworkFailures ( args . sessionId ) ;
16
- logger . info (
17
- "Successfully fetched failure network logs for session: %s" ,
18
- args . sessionId ,
19
- ) ;
15
+ try {
16
+ const failureLogs = await retrieveNetworkFailures ( args . sessionId ) ;
17
+ logger . info (
18
+ "Successfully fetched failure network logs for session: %s" ,
19
+ args . sessionId ,
20
+ ) ;
20
21
21
- // Check if there are any failures
22
- const hasFailures = failureLogs . totalFailures > 0 ;
23
- const text = hasFailures
24
- ? `${ failureLogs . totalFailures } network failure(s) found for session :\n\n${ JSON . stringify ( failureLogs . failures , null , 2 ) } `
25
- : `No network failures found for session` ;
22
+ // Check if there are any failures
23
+ const hasFailures = failureLogs . totalFailures > 0 ;
24
+ const text = hasFailures
25
+ ? `${ failureLogs . totalFailures } network failure(s) found for session :\n\n${ JSON . stringify ( failureLogs . failures , null , 2 ) } `
26
+ : `No network failures found for session` ;
26
27
27
- return {
28
- content : [
29
- {
30
- type : "text" ,
31
- text,
32
- } ,
33
- ] ,
34
- } ;
28
+ return {
29
+ content : [
30
+ {
31
+ type : "text" ,
32
+ text,
33
+ } ,
34
+ ] ,
35
+ } ;
36
+ } catch ( error ) {
37
+ logger . error ( "Failed to fetch network logs: %s" , error ) ;
38
+ throw new Error ( error instanceof Error ? error . message : String ( error ) ) ;
39
+ }
35
40
}
36
41
37
42
export default function addAutomateTools ( server : McpServer ) {
@@ -46,11 +51,16 @@ export default function addAutomateTools(server: McpServer) {
46
51
trackMCPEvent ( "getNetworkFailures" , server . server . getClientVersion ( ) ! ) ;
47
52
return await getNetworkFailures ( args ) ;
48
53
} catch ( error ) {
49
- const errorMessage = error instanceof Error ? error . message : String ( error ) ;
54
+ const errorMessage =
55
+ error instanceof Error ? error . message : String ( error ) ;
50
56
logger . error ( "Failed to fetch network logs: %s" , errorMessage ) ;
51
-
52
- trackMCPFailure ( "getNetworkFailures" , error , server . server . getClientVersion ( ) ! ) ;
53
-
57
+
58
+ trackMCPFailure (
59
+ "getNetworkFailures" ,
60
+ error ,
61
+ server . server . getClientVersion ( ) ! ,
62
+ ) ;
63
+
54
64
return {
55
65
content : [
56
66
{
0 commit comments