Linear Error Handlers
Built-in and custom error handling
The Linear plugin includes comprehensive error handling for common API issues. Error handlers automatically manage retries, logging, and recovery strategies.
New to Corsair? Learn about error handling and retry strategies.
Full Implementation: See the Linear plugin source code.
Built-in Error Handlers
The Linear plugin includes the following built-in error handlers:
Rate Limit Error
Triggers: When you exceed Linear's API rate limits.
Behavior:
- Maximum retries: 5
- Automatically respects
Retry-Afterheaders - Exponential backoff between retries
- Logs rate limit events
Example Error Messages:
"rate_limited""too many requests""429"
How to Fix:
- Reduce API call frequency
- Implement caching for frequently accessed data
- Use database queries instead of repeated API calls
- Consider batching operations
Example:
// Corsair automatically retries up to 5 times with exponential backoff
await corsair.linear.api.issues.list();
// No try-catch needed - errors are handled automaticallyAuthentication Error
Triggers: When API key is invalid, expired, or revoked.
Behavior:
- Maximum retries: 0
- No automatic retries (auth issues require manual intervention)
- Logs authentication failures
Example Error Messages:
"unauthorized""authentication failed""invalid token""token expired""token revoked""invalid api key""forbidden""access denied"
How to Fix:
- Verify your Linear API key is correct
- Check if the key has been revoked in Linear settings
- Generate a new API key if needed
- Ensure the key has appropriate permissions
Example:
// Corsair will fail immediately without retries
// Check your API key if authentication fails
await corsair.linear.api.issues.list();Not Found Error
Triggers: When a requested resource doesn't exist.
Behavior:
- Maximum retries: 0
- No automatic retries (resource doesn't exist)
- Logs not found errors
Example Error Messages:
"not found""does not exist""could not find""issue not found""team not found""project not found""comment not found""user not found"
How to Fix:
- Verify the ID is correct
- Check if the resource was deleted
- Ensure you have access to the resource
- Query the database to check if resource exists
Example:
// Corsair will fail immediately if resource doesn't exist
const issue = await corsair.linear.api.issues.get({
id: "invalid-id",
});Permission Error
Triggers: When API key lacks permissions for the requested operation.
Behavior:
- Maximum retries: 0
- No automatic retries (permissions issue)
- Logs permission denials
Example Error Messages:
"permission denied""forbidden""access denied""insufficient permissions""unauthorized access""not authorized"
How to Fix:
- Check API key permissions in Linear settings
- Ensure your API key has appropriate scopes
- Verify team/workspace membership
- Generate a new key with correct permissions
Example:
// Corsair will fail immediately if permissions are insufficient
await corsair.linear.api.projects.delete({
id: "project-id",
});Network Error
Triggers: When network connectivity issues occur.
Behavior:
- Maximum retries: 3
- Automatic retry with exponential backoff
- Logs network failures
Example Error Messages:
"network error""connection error""ECONNREFUSED""ENOTFOUND""ETIMEDOUT""fetch failed"
How to Fix:
- Check internet connectivity
- Verify firewall settings
- Check if Linear API is accessible
- Ensure DNS is working correctly
Example:
// Corsair automatically retries up to 3 times on network failures
await corsair.linear.api.issues.list();Validation Error
Triggers: When input data is invalid or malformed.
Behavior:
- Maximum retries: 0
- No automatic retries (input is invalid)
- Logs validation errors
Example Error Messages:
"validation error""invalid input""bad request""malformed request""required field missing""graphql validation error"
How to Fix:
- Verify all required fields are provided
- Check data types match API requirements
- Validate IDs exist before using them
- Review Linear's API documentation
Example:
// Corsair will fail immediately for validation errors
await corsair.linear.api.issues.create({
title: "", // Invalid: empty title
teamId: "team-id",
});
// Fix input data and try againDefault Handler
Triggers: For any errors not matched by other handlers.
Behavior:
- Maximum retries: 0
- Logs unhandled errors
- Passes error to caller
Example:
// Corsair handles all errors automatically
await corsair.linear.api.issues.create({
title: "New issue",
teamId: "team-id",
});Custom Error Handlers
You can add custom error handlers or override built-in ones:
Adding Custom Handler
linear({
errorHandlers: {
MY_CUSTOM_ERROR: {
match: (error, context) => {
// Return true if this handler should handle the error
return error.message.includes("custom error");
},
handler: async (error, context) => {
console.log(`Custom error in ${context.operation}`);
return {
maxRetries: 3,
retryDelayMs: 2000,
};
},
},
},
})Overriding Built-in Handler
linear({
errorHandlers: {
RATE_LIMIT_ERROR: {
match: (error, context) => {
return error.message.includes("rate limit");
},
handler: async (error, context) => {
// Custom rate limit handling
console.log("Custom rate limit handler");
return {
maxRetries: 10, // More retries than default
retryDelayMs: 5000, // Longer delay
};
},
},
},
})For comprehensive error handling strategies, patterns, and best practices, see the Error Handling concepts page.