mirror of
https://github.com/eyaltoledano/claude-task-master.git
synced 2026-01-30 06:12:05 +00:00
fix: improve auth-related error handling (#1477)
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
* Provides consistent error formatting and debug mode detection
|
||||
*/
|
||||
|
||||
import {
|
||||
AuthenticationError,
|
||||
isSupabaseAuthError,
|
||||
AUTH_ERROR_MESSAGES
|
||||
} from '@tm/core';
|
||||
import chalk from 'chalk';
|
||||
|
||||
/**
|
||||
@@ -36,6 +41,28 @@ export function displayError(
|
||||
const sanitized = error.getSanitizedDetails();
|
||||
console.error(chalk.red(`\n${sanitized.message}`));
|
||||
|
||||
// Show stack trace in debug mode or if forced
|
||||
if ((isDebugMode() || options.forceStack) && error.stack) {
|
||||
console.error(chalk.gray('\nStack trace:'));
|
||||
console.error(chalk.gray(error.stack));
|
||||
}
|
||||
} else if (error instanceof AuthenticationError) {
|
||||
// Handle AuthenticationError with clean message (no "Error:" prefix)
|
||||
console.error(chalk.red(`\n${error.message}`));
|
||||
|
||||
// Show stack trace in debug mode or if forced
|
||||
if ((isDebugMode() || options.forceStack) && error.stack) {
|
||||
console.error(chalk.gray('\nStack trace:'));
|
||||
console.error(chalk.gray(error.stack));
|
||||
}
|
||||
} else if (isSupabaseAuthError(error)) {
|
||||
// Handle raw Supabase auth errors with user-friendly messages
|
||||
const code = error.code;
|
||||
const userMessage = code
|
||||
? AUTH_ERROR_MESSAGES[code] || error.message
|
||||
: error.message;
|
||||
console.error(chalk.red(`\n${userMessage}`));
|
||||
|
||||
// Show stack trace in debug mode or if forced
|
||||
if ((isDebugMode() || options.forceStack) && error.stack) {
|
||||
console.error(chalk.gray('\nStack trace:'));
|
||||
|
||||
Reference in New Issue
Block a user