UNPKG

@activadee/n8n-nodes-gradio-client

Version:
33 lines (32 loc) 1.51 kB
"use strict"; // Gradio Client Error Classes Object.defineProperty(exports, "__esModule", { value: true }); exports.GradioError = void 0; const types_1 = require("./types"); class GradioError extends Error { constructor(message, type, statusCode, retryable = false) { super(message); this.name = 'GradioError'; this.type = type; this.statusCode = statusCode; this.retryable = retryable; } static fromHttpError(statusCode, statusMessage) { switch (statusCode) { case 401: return new GradioError('Authentication failed - check your HuggingFace token', types_1.GradioErrorType.AUTHENTICATION_ERROR, statusCode, false); case 404: return new GradioError('Gradio API endpoint not found or space not accessible', types_1.GradioErrorType.SPACE_NOT_FOUND, statusCode, false); case 429: return new GradioError('Rate limit exceeded - consider duplicating the space or waiting', types_1.GradioErrorType.RATE_LIMIT_ERROR, statusCode, true); case 500: case 502: case 503: case 504: return new GradioError(`Server error: ${statusMessage}`, types_1.GradioErrorType.NETWORK_ERROR, statusCode, true); default: return new GradioError(`HTTP ${statusCode}: ${statusMessage}`, types_1.GradioErrorType.NETWORK_ERROR, statusCode, statusCode >= 500); } } } exports.GradioError = GradioError;