UNPKG

cursorai-errorprompter

Version:

AI-powered runtime error fixing for developers using Cursor

25 lines (24 loc) 799 B
"use strict"; // Test file to demonstrate DevMate's error handling and GPT integration class UserService { constructor() { this.users = []; } async getUserById(id) { // Simulate a common runtime error: accessing undefined property const user = this.users.find(u => u.id === id); // Return undefined if user is not found if (!user) { return undefined; } return user; // Return the entire user object } // Helper method to get user email safely async getUserEmail(id) { const user = await this.getUserById(id); return user?.email; // Use optional chaining to safely access email } } // Test the error const userService = new UserService(); userService.getUserById(1).catch(console.error);