sickn33/agentic-awesome-skills · error · Error
Failed to fetch posts: ${error}
Error message
Failed to fetch posts: ${error} What it means
The wrapper catch in fetchUserPosts from fp-refactor: any error from the posts request (status throw, network failure, JSON parse failure) is re-thrown with the 'Failed to fetch posts' prefix, obscuring the original cause — the exact anti-pattern the skill refactors.
Source
Thrown at skills/fp-refactor/SKILL.md:183
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const data = await response.json();
return validateUser(data);
} catch (error) {
throw new Error(`Failed to fetch user: ${error}`);
}
}
async function fetchUserPosts(userId: string): Promise<Post[]> {
try {
const response = await fetch(`/api/users/${userId}/posts`);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
return await response.json();
} catch (error) {
throw new Error(`Failed to fetch posts: ${error}`);
}
}
// Complex orchestration with try-catch
async function getUserWithPosts(id: string): Promise<{ user: User; posts: Post[] } | null> {
try {
const user = await fetchUser(id);
const posts = await fetchUserPosts(id);
return { user, posts };
} catch (error) {
console.error(error);
return null;
}
}
```
#### After (fp-ts TaskEither)
View on GitHub (pinned to 58d857988f)
Solutions
- Read the suffix of the message — it contains the inner error that actually matters
- Replace message-wrapping with { cause } chaining or Either-tagged errors
- Treat 404 on posts as empty data rather than an exception where product-appropriate
Example fix
// before
catch (error) { throw new Error(`Failed to fetch posts: ${error}`) }
// after
catch (error) {
throw new Error('Failed to fetch posts', { cause: error })
} Defensive patterns
Strategy: try-catch
Try / catch
try {
await fetchUserPosts(userId)
} catch (e) {
const inner = /Failed to fetch posts: (.*)/.exec(String(e))?.[1] ?? String(e)
// branch on inner cause
} Prevention
- Prefer error.cause chaining over message-string wrapping
- Alert on the inner error, not the wrapper
When it happens
Trigger: Any exception while fetching /api/users/:id/posts, including the HTTP error throw two lines above, offline fetch rejection, or invalid JSON in a 200 response.
Common situations: Feed widgets failing silently behind a generic banner; log aggregation counting all causes as one error; nested wrappers producing 'Failed to fetch posts: Error: HTTP error: 500' strings.
Related errors
- Failed to fetch user: ${error}
- HTTP error: ${response.status}
- HTTP ${response.status}: ${response.statusText}
- HTTP ${response.status}
- HTTP ${posts.status}
AI-assisted analysis of sickn33/agentic-awesome-skills@58d857988f (2026-08-26).
Data as JSON: /api/errors/1c9a6bf48c4919d1.
Report an issue: GitHub.