-
Notifications
You must be signed in to change notification settings - Fork 7
fix : added proper error handling to failure logs #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
48abda5
Added proper error handling to failure logs
tech-sushant f3e8b9c
Moved all the utils related to getFailure tool moved to failure-utils
tech-sushant 0e260c6
Refactor failure log retrieval functions to return formatted strings …
tech-sushant bbd8049
Merge branch 'main' into err-handling
tech-sushant ecedf68
Updated TC as per new refactoring
tech-sushant 66e71a7
Removing unused imports
tech-sushant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,11 @@ import { | |
retrieveCrashLogs, | ||
} from "./failurelogs-utils/app-automate.js"; | ||
import { trackMCP } from "../lib/instrumentation.js"; | ||
import { AppAutomateLogType, AutomateLogType, SessionType } from "../lib/constants.js"; | ||
import { | ||
AppAutomateLogType, | ||
AutomateLogType, | ||
SessionType, | ||
} from "../lib/constants.js"; | ||
|
||
type LogType = AutomateLogType | AppAutomateLogType; | ||
type SessionTypeValues = SessionType; | ||
|
@@ -86,79 +90,85 @@ export async function getFailureLogs(args: { | |
], | ||
}; | ||
} | ||
|
||
let response; | ||
// eslint-disable-next-line no-useless-catch | ||
try { | ||
for (const logType of validLogTypes) { | ||
switch (logType) { | ||
case AutomateLogType.NetworkLogs: { | ||
const logs = await retrieveNetworkFailures(args.sessionId); | ||
response = await retrieveNetworkFailures(args.sessionId); | ||
results.push({ | ||
type: "text", | ||
text: | ||
logs.length > 0 | ||
? `Network Failures (${logs.length} found):\n${JSON.stringify(logs, null, 2)}` | ||
: "No network failures found", | ||
response.message || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. directly return the result of these conditionals in the response (for other methods as well) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain this change a bit ? |
||
(response.logs && response.logs.length > 0 | ||
? `Network Failures (${response.logs.length} found):\n${JSON.stringify(response.logs, null, 2)}` | ||
: "No network failures found"), | ||
}); | ||
break; | ||
} | ||
|
||
case AutomateLogType.SessionLogs: { | ||
const logs = await retrieveSessionFailures(args.sessionId); | ||
response = await retrieveSessionFailures(args.sessionId); | ||
results.push({ | ||
type: "text", | ||
text: | ||
logs.length > 0 | ||
? `Session Failures (${logs.length} found):\n${JSON.stringify(logs, null, 2)}` | ||
: "No session failures found", | ||
response.message || | ||
(response.logs && response.logs.length > 0 | ||
? `Session Failures (${response.logs.length} found):\n${JSON.stringify(response.logs, null, 2)}` | ||
: "No session failures found"), | ||
}); | ||
break; | ||
} | ||
|
||
case AutomateLogType.ConsoleLogs: { | ||
const logs = await retrieveConsoleFailures(args.sessionId); | ||
response = await retrieveConsoleFailures(args.sessionId); | ||
results.push({ | ||
type: "text", | ||
text: | ||
logs.length > 0 | ||
? `Console Failures (${logs.length} found):\n${JSON.stringify(logs, null, 2)}` | ||
: "No console failures found", | ||
response.message || | ||
(response.logs && response.logs.length > 0 | ||
? `Console Failures (${response.logs.length} found):\n${JSON.stringify(response.logs, null, 2)}` | ||
: "No console failures found"), | ||
}); | ||
break; | ||
} | ||
|
||
case AppAutomateLogType.DeviceLogs: { | ||
const logs = await retrieveDeviceLogs(args.sessionId, args.buildId!); | ||
response = await retrieveDeviceLogs(args.sessionId, args.buildId!); | ||
results.push({ | ||
type: "text", | ||
text: | ||
logs.length > 0 | ||
? `Device Failures (${logs.length} found):\n${JSON.stringify(logs, null, 2)}` | ||
: "No device failures found", | ||
response.message || | ||
(response.logs && response.logs.length > 0 | ||
? `Device Failures (${response.logs.length} found):\n${JSON.stringify(response.logs, null, 2)}` | ||
: "No device failures found"), | ||
}); | ||
break; | ||
} | ||
|
||
case AppAutomateLogType.AppiumLogs: { | ||
const logs = await retrieveAppiumLogs(args.sessionId, args.buildId!); | ||
response = await retrieveAppiumLogs(args.sessionId, args.buildId!); | ||
results.push({ | ||
type: "text", | ||
text: | ||
logs.length > 0 | ||
? `Appium Failures (${logs.length} found):\n${JSON.stringify(logs, null, 2)}` | ||
: "No Appium failures found", | ||
response.message || | ||
(response.logs && response.logs.length > 0 | ||
? `Appium Failures (${response.logs.length} found):\n${JSON.stringify(response.logs, null, 2)}` | ||
: "No Appium failures found"), | ||
}); | ||
break; | ||
} | ||
|
||
case AppAutomateLogType.CrashLogs: { | ||
const logs = await retrieveCrashLogs(args.sessionId, args.buildId!); | ||
response = await retrieveCrashLogs(args.sessionId, args.buildId!); | ||
results.push({ | ||
type: "text", | ||
text: | ||
logs.length > 0 | ||
? `Crash Failures (${logs.length} found):\n${JSON.stringify(logs, null, 2)}` | ||
: "No crash failures found", | ||
response.message || | ||
(response.logs && response.logs.length > 0 | ||
? `Crash Failures (${response.logs.length} found):\n${JSON.stringify(response.logs, null, 2)}` | ||
: "No crash failures found"), | ||
}); | ||
break; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.