fix(myTischtennis): improve error handling for Playwright login and account verification

- Enhanced error handling in MyTischtennisClient and MyTischtennisService to provide clearer feedback when browser executables are missing.
- Updated responses to include specific error messages and status codes, improving user guidance for setup requirements.
- Refactored MyTischtennisDialog and MyTischtennisAccount components to handle API response errors more effectively, ensuring robust login and account management processes.
This commit is contained in:
Torsten Schulz (local)
2026-02-27 17:23:03 +01:00
parent 4e81a1c4a7
commit 12bba26ff1
4 changed files with 37 additions and 10 deletions

View File

@@ -520,10 +520,17 @@ class MyTischtennisClient {
cookie
};
} catch (error) {
console.error('[myTischtennisClient.playwright] Browser login failed:', error?.message || error);
const rawMessage = String(error?.message || error || 'Playwright-Login fehlgeschlagen');
const isMissingBrowserExecutable = /Executable doesn't exist|download new browsers|playwright install/i.test(rawMessage);
const normalizedError = isMissingBrowserExecutable
? 'Playwright-Browser ist auf dem Server nicht installiert. Bitte "npx playwright install chromium" ausführen.'
: rawMessage;
console.error('[myTischtennisClient.playwright] Browser login failed:', normalizedError);
return {
success: false,
error: error?.message || 'Playwright-Login fehlgeschlagen'
error: normalizedError,
requiresSetup: isMissingBrowserExecutable,
status: isMissingBrowserExecutable ? 503 : 400
};
} finally {
if (context) {

View File

@@ -247,20 +247,25 @@ class MyTischtennisService {
effectiveLoginResult = playwrightResult;
} else {
console.warn('[myTischtennisService.verifyLogin] Playwright-Fallback fehlgeschlagen:', playwrightResult.error);
const isSetupError = !!playwrightResult.requiresSetup || playwrightResult.status === 503;
effectiveLoginResult = {
success: false,
error: playwrightResult.error || 'Playwright-Fallback fehlgeschlagen',
requiresCaptcha: true,
status: 400
requiresCaptcha: !isSetupError,
status: isSetupError ? 503 : 400
};
}
} catch (playwrightError) {
console.warn('[myTischtennisService.verifyLogin] Playwright-Fallback Exception:', playwrightError?.message || playwrightError);
const rawMessage = String(playwrightError?.message || playwrightError || '');
const isSetupError = /Executable doesn't exist|download new browsers|playwright install/i.test(rawMessage);
effectiveLoginResult = {
success: false,
error: `Playwright-Fallback Exception: ${playwrightError?.message || 'Unbekannter Fehler'}`,
requiresCaptcha: true,
status: 400
error: isSetupError
? 'Playwright-Browser ist auf dem Server nicht installiert. Bitte "npx playwright install chromium" ausführen.'
: `Playwright-Fallback Exception: ${playwrightError?.message || 'Unbekannter Fehler'}`,
requiresCaptcha: !isSetupError,
status: isSetupError ? 503 : 400
};
}
}