MCPcopy Create free account
hub / github.com/Noumena-Network/code / getFileSystemErrorMessage

Function getFileSystemErrorMessage

src/utils/toolResultStorage.ts:1043–1066  ·  view source on GitHub ↗

* Get a human-readable error message from a filesystem error

(error: Error)

Source from the content-addressed store, hash-verified

1041 * Get a human-readable error message from a filesystem error
1042 */
1043function getFileSystemErrorMessage(error: Error): string {
1044 // Node.js filesystem errors have a 'code' property
1045 // eslint-disable-next-line no-restricted-syntax -- uses .path, not just .code
1046 const nodeError = error as NodeJS.ErrnoException
1047 if (nodeError.code) {
1048 switch (nodeError.code) {
1049 case 'ENOENT':
1050 return `Directory not found: ${nodeError.path ?? 'unknown path'}`
1051 case 'EACCES':
1052 return `Permission denied: ${nodeError.path ?? 'unknown path'}`
1053 case 'ENOSPC':
1054 return 'No space left on device'
1055 case 'EROFS':
1056 return 'Read-only file system'
1057 case 'EMFILE':
1058 return 'Too many open files'
1059 case 'EEXIST':
1060 return `File already exists: ${nodeError.path ?? 'unknown path'}`
1061 default:
1062 return `${nodeError.code}: ${nodeError.message}`
1063 }
1064 }
1065 return error.message
1066}

Callers 1

persistToolResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected