feat: Enhanced model load error diagnostics with structured error types#98
feat: Enhanced model load error diagnostics with structured error types#98Sumanth-806307 wants to merge 3 commits into
Conversation
Summary of ChangesHello @Sumanth-806307, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the diagnostic capabilities for model loading failures by introducing a structured error handling system. It classifies errors into specific categories, provides users with actionable guidance and retry suggestions, and enhances debugging information available in console logs. This change aims to improve the user experience by replacing generic error messages with clear, contextual feedback, and sets the foundation for future features like automatic retry logic. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly enhances error diagnostics for model loading failures by introducing structured error types and improved error classification. The changes provide more actionable guidance to users and better debugging information, which is a substantial improvement to the application's robustness and user experience. The implementation of ModelLoadError and createModelLoadError provides a solid foundation for consistent error handling. My main feedback concerns a minor inconsistency in the error code definitions and their usage.
| WORKER_INIT_FAILED = "worker_init_failed", | ||
| WEBGPU_INIT_FAILED = "webgpu_init_failed", | ||
| CACHE_INVALID = "cache_invalid", | ||
| NETWORK_ERROR = "network_error", |
There was a problem hiding this comment.
The NETWORK_ERROR enum member is defined in ModelLoadErrorCode but is not currently used in the classifyError method in app/client/webllm.ts. All network-related errors are mapped to ARTIFACT_FETCH_FAILED. Consider either removing NETWORK_ERROR if ARTIFACT_FETCH_FAILED is intended to cover all network issues, or add specific logic in classifyError to utilize NETWORK_ERROR if it represents a distinct category of network failures.
Summary
Implements Phase 1 of issue #96: Enhanced error diagnostics for model loading failures.
This PR addresses the model loading failures reported in issue #85 by introducing structured error handling, classification, and user-actionable error messages.
Changes Made
1. Added Structured Error Types (
app/client/api.ts)ModelLoadErrorCodeenum with 7 error categoriesModelLoadErrorinterface extending Error with diagnostic fieldscreateModelLoadErrorhelper function2. Enhanced Error Classification (
app/client/webllm.ts)classifyErrormethod that categorizes errors into:webgpu_init_failed- Browser lacks WebGPU supportartifact_fetch_failed- Network/CDN download failurescache_invalid- Cache corruption issuesworker_init_failed- Web Worker startup failuresunknown_error- Unclassified errors3. Improved Error Display (
app/store/chat.ts)onErrorhandler to display structured errors4. Documentation
Benefits
✅ Better Diagnostics: Every error now has a classification code
✅ Actionable Guidance: Users get specific steps to resolve issues
✅ Improved Debugging: Console logs include structured error details
✅ User Experience: Clear, helpful error messages instead of technical jargon
✅ Future-Ready: Foundation for retry logic (Phase 2) and telemetry
Testing
Manual Testing Recommendations
artifact_fetch_failedcache_invalidRelated Issues
Closes #96
Next Steps (Future PRs)
Screenshots
Before
After