Improves API error handling in cleanup command
Enhances error reporting for different API error scenarios by: - Adding a generic API error handler for unspecified status codes - Preserving more detailed error information when possible - Providing clearer user notifications for various error types
This commit is contained in:
1 file changed
+8
-4
@@ -81,10 +81,14 @@ export class CleanupCommand {
|
|||||||
new Notice('API key error. Please check your settings.');
|
new Notice('API key error. Please check your settings.');
|
||||||
} else if (error instanceof TextTooLongError) {
|
} else if (error instanceof TextTooLongError) {
|
||||||
new Notice(error.message);
|
new Notice(error.message);
|
||||||
} else if (error instanceof ApiError && (error.status === 401 || error.status === 403)) {
|
} else if (error instanceof ApiError) {
|
||||||
new Notice('API key was rejected by the server. Please verify your key.');
|
if (error.status === 401 || error.status === 403) {
|
||||||
} else if (error instanceof ApiError && error.status === 429) {
|
new Notice('API key was rejected by the server. Please verify your key.');
|
||||||
new Notice('Rate limited by API. Please wait and try again.');
|
} else if (error.status === 429) {
|
||||||
|
new Notice('Rate limited by API. Please wait and try again.');
|
||||||
|
} else {
|
||||||
|
new Notice(`API error (${error.status}): ${error.message}`);
|
||||||
|
}
|
||||||
} else if (error instanceof ServiceUnavailableError) {
|
} else if (error instanceof ServiceUnavailableError) {
|
||||||
new Notice(error.message);
|
new Notice(error.message);
|
||||||
} else if (error instanceof InvalidResponseError) {
|
} else if (error instanceof InvalidResponseError) {
|
||||||
|
|||||||
Reference in new issue
Block a user