fix: improve edge function error handling and display

This commit is contained in:
2026-02-06 20:04:46 +03:00
parent e97bc0f56b
commit 57f9d9e7ff
3 changed files with 30 additions and 6 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "pezkuwi-telegram-miniapp",
"version": "1.0.121",
"version": "1.0.122",
"type": "module",
"description": "Pezkuwichain Telegram Mini App - Forum, Announcements, Rewards",
"author": "Pezkuwichain Team",
+26 -2
View File
@@ -16,8 +16,32 @@ export async function signInWithTelegram(initData: string) {
});
if (error) {
console.error('[Auth] Telegram sign-in failed:', error);
throw error;
// Extract more detailed error message
let errorMessage = error.message || 'Unknown error';
// Check if there's additional context in the error
if (error.context?.body) {
try {
const bodyError = JSON.parse(error.context.body);
if (bodyError.error) {
errorMessage = bodyError.error;
}
} catch {
// Body is not JSON, use as-is
if (typeof error.context.body === 'string') {
errorMessage = error.context.body;
}
}
}
console.error('[Auth] Telegram sign-in failed:', errorMessage);
throw new Error(errorMessage);
}
// Check if edge function returned an error in data
if (data?.error) {
console.error('[Auth] Edge function error:', data.error);
throw new Error(data.error);
}
if (data?.session) {
+3 -3
View File
@@ -1,5 +1,5 @@
{
"version": "1.0.121",
"buildTime": "2026-02-06T16:48:42.195Z",
"buildNumber": 1770396522198
"version": "1.0.122",
"buildTime": "2026-02-06T17:04:46.943Z",
"buildNumber": 1770397486943
}