MCPcopy
hub / github.com/di-sukharev/opencommit / formatUserFriendlyError

Function formatUserFriendlyError

out/cli.cjs:74529–74620  ·  view source on GitHub ↗
(error, provider, context)

Source from the content-addressed store, hash-verified

74527 if (endpointLabel) {
74528 return `The configured API endpoint (${endpointLabel}) is temporarily unavailable.`;
74529 }
74530 if (context?.baseURL) {
74531 return "The configured API endpoint is temporarily unavailable.";
74532 }
74533 return `The ${provider} service is temporarily unavailable.`;
74534}
74535function formatUserFriendlyError(error, provider, context) {
74536 const billingUrl = PROVIDER_BILLING_URLS[provider] || null;
74537 if (error instanceof InsufficientCreditsError) {
74538 return {
74539 title: "Insufficient Credits",
74540 message: `Your ${provider} account has insufficient credits or quota.`,
74541 helpUrl: billingUrl,
74542 suggestion: "Add credits to your account to continue using the service."
74543 };
74544 }
74545 if (error instanceof RateLimitError3) {
74546 const retryMsg = error.retryAfter ? `Please wait ${error.retryAfter} seconds before retrying.` : "Please wait a moment before retrying.";
74547 return {
74548 title: "Rate Limit Exceeded",
74549 message: `You've made too many requests to ${provider}.`,
74550 helpUrl: billingUrl,
74551 suggestion: retryMsg
74552 };
74553 }
74554 if (error instanceof ServiceUnavailableError) {
74555 return {
74556 title: "Service Unavailable",
74557 message: getServiceUnavailableMessage(provider, context),
74558 helpUrl: null,
74559 suggestion: "Please try again in a few moments."
74560 };
74561 }
74562 if (error instanceof AuthenticationError3) {
74563 return {
74564 title: "Authentication Failed",
74565 message: `Your ${provider} API key is invalid or expired.`,
74566 helpUrl: billingUrl,
74567 suggestion: "Run `oco setup` to configure a valid API key."
74568 };
74569 }
74570 if (error instanceof ModelNotFoundError) {
74571 return {
74572 title: "Model Not Found",
74573 message: `The model '${error.modelName}' is not available for ${provider}.`,
74574 helpUrl: null,
74575 suggestion: "Run `oco setup` to select a valid model."
74576 };
74577 }
74578 if (isInsufficientCreditsError(error)) {
74579 return {
74580 title: "Insufficient Credits",
74581 message: `Your ${provider} account has insufficient credits or quota.`,
74582 helpUrl: billingUrl,
74583 suggestion: "Add credits to your account to continue using the service."
74584 };
74585 }
74586 if (isRateLimitError(error)) {

Callers 1

Calls 6

isRateLimitErrorFunction · 0.70
isApiKeyErrorFunction · 0.70
isModelNotFoundErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…