MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / extractErrorMessage

Function extractErrorMessage

src/utils/engineErrorHandler.ts:52–85  ·  view source on GitHub ↗

* Extracts the error message from various error structures

(error: unknown)

Source from the content-addressed store, hash-verified

50 * Extracts the error message from various error structures
51 */
52function extractErrorMessage(error: unknown): string {
53 if (error instanceof Error) {
54 return error.message;
55 }
56
57 // API error response structures
58 const apiError = (error as any)?.response?.data?.error;
59 if (apiError) {
60 if (typeof apiError === 'string') {
61 return apiError;
62 }
63 if (apiError.message) {
64 return apiError.message;
65 }
66 }
67
68 // Direct error data
69 const errorData = (error as any)?.error;
70 if (errorData) {
71 if (typeof errorData === 'string') {
72 return errorData;
73 }
74 if (errorData.message) {
75 return errorData.message;
76 }
77 }
78
79 // Fallback
80 if (typeof error === 'string') {
81 return error;
82 }
83
84 return 'An unknown error occurred';
85}
86
87/**
88 * Checks if the error message indicates a model not found error

Callers 1

normalizeEngineErrorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…