mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-16 14:16:16 -08:00
fix: suppress snackbar for portal status checks and log them
Refactor error handling for Xtream requests to avoid showing user snackbars when the request is a portal status check (get_account_info). Instead of treating these errors as full failures, log them with console.log to indicate the portal may be unavailable and return early. Key changes: - Introduce isStatusCheck detection in electron and pwa services. - Replace console.error + snackbar with console.log for status checks. - Only display snackbars for non-status-check errors. - Add a console.log when pwa response has no payload for status checks. This prevents unnecessary user-facing error popups for routine portal health/status checks while keeping errors surfaced for other requests.
This commit is contained in:
1 parent
a948ce0265
commit
7918c4849d
2 files changed
+35
-12
No files matched your search
@@ -226,16 +226,28 @@ export class ElectronService extends DataService {
|
||||
window.postMessage(result);
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
console.error('Xtream request error:', error.message);
|
||||
this.snackBar.open(
|
||||
`Error: ${error.message ?? 'Failed to connect to Xtream server'}, status: ${
|
||||
error.status ?? 500
|
||||
}`,
|
||||
'Close',
|
||||
{
|
||||
duration: 5000,
|
||||
}
|
||||
);
|
||||
const isStatusCheck = payload.params?.action === 'get_account_info';
|
||||
|
||||
// Log error to console
|
||||
if (isStatusCheck) {
|
||||
console.log('Portal status check failed - portal may be unavailable:', error.message || error);
|
||||
} else {
|
||||
console.error('Xtream request error:', error.message);
|
||||
}
|
||||
|
||||
// Only show snackbar for non-status-check requests
|
||||
if (!isStatusCheck) {
|
||||
this.snackBar.open(
|
||||
`Error: ${error.message ?? 'Failed to connect to Xtream server'}, status: ${
|
||||
error.status ?? 500
|
||||
}`,
|
||||
'Close',
|
||||
{
|
||||
duration: 5000,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
type: ERROR,
|
||||
status: error.status ?? 500,
|
||||
|
||||
@@ -186,7 +186,10 @@ export class PwaService extends DataService {
|
||||
);
|
||||
|
||||
if (!(response as any).payload) {
|
||||
if (payload.params.action === 'get_account_info') return;
|
||||
if (payload.params.action === 'get_account_info') {
|
||||
console.log('Portal status check failed - portal may be unavailable:', (response as any).message || 'No payload received');
|
||||
return;
|
||||
}
|
||||
|
||||
result = {
|
||||
type: ERROR,
|
||||
@@ -204,7 +207,15 @@ export class PwaService extends DataService {
|
||||
}
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
if (payload.params.action === 'get_account_info') return;
|
||||
const isStatusCheck = payload.params.action === 'get_account_info';
|
||||
|
||||
// Log error to console
|
||||
if (isStatusCheck) {
|
||||
console.log('Portal status check failed - portal may be unavailable:', error.message || error);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error('Xtream request error:', error.message);
|
||||
this.snackBar.open(
|
||||
`Error: ${error.message ?? ' Unknown error'}, status: ${
|
||||
error.status ?? 500
|
||||
|
||||
Reference in new issue
Block a user