mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-19 05:03:57 +00:00
Improved error handling and added protection against race conditions in the bot controller. Extracted Microsoft domain verification for better maintainability. Added support for custom activity managers and improved documentation.
This commit is contained in:
@@ -9,6 +9,24 @@ export function getErrorMessage(error: unknown): string {
|
||||
return error instanceof Error ? error.message : String(error)
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a standardized error message for logging
|
||||
* Ensures consistent error message formatting across all modules
|
||||
*
|
||||
* @param context - Context string (e.g., 'SEARCH-BING', 'LOGIN')
|
||||
* @param error - Error object or unknown value
|
||||
* @param prefix - Optional custom prefix (defaults to 'Error')
|
||||
* @returns Formatted error message
|
||||
*
|
||||
* @example
|
||||
* formatErrorMessage('SEARCH', err) // 'Error in SEARCH: Network timeout'
|
||||
* formatErrorMessage('LOGIN', err, 'Failed') // 'Failed in LOGIN: Invalid credentials'
|
||||
*/
|
||||
export function formatErrorMessage(context: string, error: unknown, prefix: string = 'Error'): string {
|
||||
const errorMsg = getErrorMessage(error)
|
||||
return `${prefix} in ${context}: ${errorMsg}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class for common operations
|
||||
* IMPROVED: Added comprehensive documentation
|
||||
|
||||
Reference in New Issue
Block a user