Add user-friendly error messages for API failures#31
Open
robertmclaws wants to merge 1 commit intosupermemoryai:mainfrom
Open
Add user-friendly error messages for API failures#31robertmclaws wants to merge 1 commit intosupermemoryai:mainfrom
robertmclaws wants to merge 1 commit intosupermemoryai:mainfrom
Conversation
The plugin previously swallowed all API errors silently via `.catch(() => null)` in context-hook.js, making 400/401/403/429 errors indistinguishable from "no memories found". This made it nearly impossible for users to diagnose authentication, permission, or rate-limit issues. Changes: - Add src/lib/error-helpers.js with getUserFriendlyError(), isRetryableError(), and isBenignError() utilities that map SDK error status codes to actionable messages - Replace .catch(() => null) in context-hook.js with error-aware handlers that surface non-benign errors via <supermemory-status> - Update catch blocks in summary-hook.js, add-memory.js, search-memory.js, and save-project-memory.js to use getUserFriendlyError() instead of raw err.message Relates to supermemoryai#26 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Just an FYI, this came about because the plugin installation process used Powershell to add the Supermemory key, which only kept it in the Environment variables for the session. When the session restarted, the key was gone, and subagents started throwing 400 errors without source information that had to be tracked down. This PR attempts to solve that problem by handling the API exceptions and turning them into user-actionable error messages so they don't have to waste tokens solving the problem. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.catch(() => null)incontext-hook.js, making 400/401/403/429 errors indistinguishable from "No previous memories found". Users had zero indication when their API key was invalid, expired, or rate-limited.src/lib/error-helpers.js) that maps SDK error status codes to actionable, user-facing messages with links to relevant console/pricing pages..catch(() => null)incontext-hook.jswith error-aware handlers that distinguish benign errors (404, network blips) from real problems (400, 401, 403, 429, 5xx) and surface the latter via<supermemory-status>tags.summary-hook.js,add-memory.js,search-memory.js, andsave-project-memory.jsto use the newgetUserFriendlyError()helper.Relates to #26
Files changed
src/lib/error-helpers.jsgetUserFriendlyError(),isRetryableError(),isBenignError()src/context-hook.js.catch(() => null)with error-aware handlers; surface API errorssrc/summary-hook.jsgetUserFriendlyError()in catch blocksrc/add-memory.jsgetUserFriendlyError()in catch blocksrc/search-memory.jsgetUserFriendlyError()in catch blocksrc/save-project-memory.jsgetUserFriendlyError()in catch blockDesign decisions
err.statusproperty checks rather thaninstanceofSDK error classes to avoid bundling/import-path issuesnullsilently, matching the previous graceful behavior<supermemory-status>blockTest plan
🤖 Generated with Claude Code