refactor: change error number.

This commit is contained in:
liqiang-fit2cloud 2025-12-09 19:02:49 +08:00
parent ff3ecb36d4
commit d68acede6f
2 changed files with 5 additions and 4 deletions

View File

@ -119,7 +119,7 @@ sys.stdout.flush()
result = json.loads(result_line[-1].split(":", 1)[1])
if result.get('code') == 200:
return result.get('data')
raise Exception(result.get('msg'))
raise Exception(result.get('msg') + (f'\n{subprocess_result.stderr}' if subprocess_result.stderr else ''))
def _generate_mcp_server_code(self, _code, params):
# 解析代码,提取导入语句和函数定义

View File

@ -166,7 +166,7 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
if (is_sandbox_user() && banned_hosts && *banned_hosts) {
if (ip[0] && match_banned_ip(ip, banned_hosts)) {
fprintf(stderr, "[sandbox] 🚫 Access to IP %s is banned\n", ip);
fprintf(stderr, "Permission denied to access %s.\n", ip);
errno = EACCES; // Permission denied
return -1;
}
@ -188,8 +188,9 @@ int getaddrinfo(const char *node, const char *service,
if (!is_ip) {
// 仅对域名进行阻塞
if (match_banned_domain(node, banned_hosts)) {
fprintf(stderr, "[sandbox] 🚫 Access to host %s is banned (DNS blocked)\n", node);
return EAI_FAIL;
fprintf(stderr, "Permission denied to access %s.\n", node);
errno = EACCES;
return EAI_SYSTEM;
}
}
}