diff --git a/app/(app)/loading/page.tsx b/app/(app)/loading/page.tsx
index 721004e..0cf0231 100644
--- a/app/(app)/loading/page.tsx
+++ b/app/(app)/loading/page.tsx
@@ -13,6 +13,7 @@ import {
CardTitle,
} from '@/components/ui/card';
import { Button } from '@/components/ui/button';
+import { Bug, MoveLeft } from 'lucide-react';
const LoadingPage = (): JSX.Element => {
const [progress, setProgress] = useState(0);
@@ -24,7 +25,7 @@ const LoadingPage = (): JSX.Element => {
try {
setProgress(0);
if (!xmlContent) {
- throw new Error('No XML data found');
+ throw new Error('No XML data found in the file.');
}
setProgress(25);
const jsonData = convertToJson(xmlContent);
@@ -36,7 +37,7 @@ const LoadingPage = (): JSX.Element => {
router.push('/results');
} catch (err) {
if (err instanceof Error) {
- setError(`${err.name} : ${err.message}`);
+ setError(`${err.message}`);
}
}
}, [router]);
@@ -61,8 +62,8 @@ const LoadingPage = (): JSX.Element => {
{error ? (
-
Error:
-
{error}
+
Error:
+
{error}
) : (
@@ -73,9 +74,13 @@ const LoadingPage = (): JSX.Element => {
{error && (
-
+
)}
diff --git a/lib/xml-parser.ts b/lib/xml-parser.ts
index 7f34779..5e7093e 100644
--- a/lib/xml-parser.ts
+++ b/lib/xml-parser.ts
@@ -127,19 +127,25 @@ const getTestSuites = (suites: any): TestSuite[] => {
return result;
};
+const errorMessage = 'Error while processing the XML file.';
+
const getTestResults = (jsonData: any): TestResult => {
const testResult = jsonData['testng-results'];
- const mapToResult: TestResult = {
- failed: parseInt(testResult.failed),
- passed: parseInt(testResult.passed),
- skipped: parseInt(testResult.skipped),
- ignored: parseInt(testResult.ignored),
- total: parseInt(testResult.total),
- test_suites: getTestSuites(testResult.suite),
- };
-
- return mapToResult;
+ try {
+ const mapToResult: TestResult = {
+ failed: parseInt(testResult.failed),
+ passed: parseInt(testResult.passed),
+ skipped: parseInt(testResult.skipped),
+ ignored: parseInt(testResult.ignored),
+ total: parseInt(testResult.total),
+ test_suites: getTestSuites(testResult.suite),
+ };
+ return mapToResult;
+ /* eslint-disable @typescript-eslint/no-unused-vars */
+ } catch (error) {
+ throw new Error(errorMessage);
+ }
};
const convertToJson = (data: string): string | null => {
@@ -152,8 +158,7 @@ const convertToJson = (data: string): string | null => {
},
(error, result) => {
if (error) {
- alert(`Error parsing XML file: ${error.name} - ${error.message}`);
- return null;
+ throw new Error(errorMessage);
}
jsonData = result;
}