Inline explain_exit_code and clean diagnostics_check docs
Moved the explain_exit_code function directly into api.func, removing external dependency loading. Also cleaned up merge conflict markers and unified documentation for diagnostics_check in build.func.
This commit is contained in:
parent
7b56a79964
commit
36f5e32d48
@ -28,21 +28,96 @@
|
||||
# ==============================================================================
|
||||
|
||||
# ==============================================================================
|
||||
# SECTION 1: DEPENDENCY LOADING
|
||||
# SECTION 1: ERROR CODE DESCRIPTIONS
|
||||
# ==============================================================================
|
||||
|
||||
# Load error_handler.func for explain_exit_code() function
|
||||
# This provides centralized error code descriptions (exit codes 1-255, shell, package managers, databases, custom Proxmox codes)
|
||||
if [[ -z "${COMMUNITY_SCRIPTS_BASE_URL:-}" ]]; then
|
||||
COMMUNITY_SCRIPTS_BASE_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main"
|
||||
fi
|
||||
# ------------------------------------------------------------------------------
|
||||
# explain_exit_code()
|
||||
#
|
||||
# - Maps numeric exit codes to human-readable error descriptions
|
||||
# - Supports:
|
||||
# * Generic/Shell errors (1, 2, 126, 127, 128, 130, 137, 139, 143)
|
||||
# * Package manager errors (APT, DPKG: 100, 101, 255)
|
||||
# * Node.js/npm errors (243-249, 254)
|
||||
# * Python/pip/uv errors (210-212)
|
||||
# * PostgreSQL errors (231-234)
|
||||
# * MySQL/MariaDB errors (241-244)
|
||||
# * MongoDB errors (251-254)
|
||||
# * Proxmox custom codes (200-231)
|
||||
# - Returns description string for given exit code
|
||||
# - Shared function with error_handler.func for consistency
|
||||
# ------------------------------------------------------------------------------
|
||||
explain_exit_code() {
|
||||
local code="$1"
|
||||
case "$code" in
|
||||
# --- Generic / Shell ---
|
||||
1) echo "General error / Operation not permitted" ;;
|
||||
2) echo "Misuse of shell builtins (e.g. syntax error)" ;;
|
||||
126) echo "Command invoked cannot execute (permission problem?)" ;;
|
||||
127) echo "Command not found" ;;
|
||||
128) echo "Invalid argument to exit" ;;
|
||||
130) echo "Terminated by Ctrl+C (SIGINT)" ;;
|
||||
137) echo "Killed (SIGKILL / Out of memory?)" ;;
|
||||
139) echo "Segmentation fault (core dumped)" ;;
|
||||
143) echo "Terminated (SIGTERM)" ;;
|
||||
|
||||
if ! declare -f explain_exit_code >/dev/null 2>&1; then
|
||||
source <(curl -fsSL "${COMMUNITY_SCRIPTS_BASE_URL}/misc/error_handler.func") || {
|
||||
echo "Failed to load error_handler.func" >&2
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
# --- Package manager / APT / DPKG ---
|
||||
100) echo "APT: Package manager error (broken packages / dependency problems)" ;;
|
||||
101) echo "APT: Configuration error (bad sources.list, malformed config)" ;;
|
||||
255) echo "DPKG: Fatal internal error" ;;
|
||||
|
||||
# --- Node.js / npm / pnpm / yarn ---
|
||||
243) echo "Node.js: Out of memory (JavaScript heap out of memory)" ;;
|
||||
245) echo "Node.js: Invalid command-line option" ;;
|
||||
246) echo "Node.js: Internal JavaScript Parse Error" ;;
|
||||
247) echo "Node.js: Fatal internal error" ;;
|
||||
248) echo "Node.js: Invalid C++ addon / N-API failure" ;;
|
||||
249) echo "Node.js: Inspector error" ;;
|
||||
254) echo "npm/pnpm/yarn: Unknown fatal error" ;;
|
||||
|
||||
# --- Python / pip / uv ---
|
||||
210) echo "Python: Virtualenv / uv environment missing or broken" ;;
|
||||
211) echo "Python: Dependency resolution failed" ;;
|
||||
212) echo "Python: Installation aborted (permissions or EXTERNALLY-MANAGED)" ;;
|
||||
|
||||
# --- PostgreSQL ---
|
||||
231) echo "PostgreSQL: Connection failed (server not running / wrong socket)" ;;
|
||||
232) echo "PostgreSQL: Authentication failed (bad user/password)" ;;
|
||||
233) echo "PostgreSQL: Database does not exist" ;;
|
||||
234) echo "PostgreSQL: Fatal error in query / syntax" ;;
|
||||
|
||||
# --- MySQL / MariaDB ---
|
||||
241) echo "MySQL/MariaDB: Connection failed (server not running / wrong socket)" ;;
|
||||
242) echo "MySQL/MariaDB: Authentication failed (bad user/password)" ;;
|
||||
243) echo "MySQL/MariaDB: Database does not exist" ;;
|
||||
244) echo "MySQL/MariaDB: Fatal error in query / syntax" ;;
|
||||
|
||||
# --- MongoDB ---
|
||||
251) echo "MongoDB: Connection failed (server not running)" ;;
|
||||
252) echo "MongoDB: Authentication failed (bad user/password)" ;;
|
||||
253) echo "MongoDB: Database not found" ;;
|
||||
254) echo "MongoDB: Fatal query error" ;;
|
||||
|
||||
# --- Proxmox Custom Codes ---
|
||||
200) echo "Custom: Failed to create lock file" ;;
|
||||
203) echo "Custom: Missing CTID variable" ;;
|
||||
204) echo "Custom: Missing PCT_OSTYPE variable" ;;
|
||||
205) echo "Custom: Invalid CTID (<100)" ;;
|
||||
209) echo "Custom: Container creation failed" ;;
|
||||
210) echo "Custom: Cluster not quorate" ;;
|
||||
214) echo "Custom: Not enough storage space" ;;
|
||||
215) echo "Custom: Container ID not listed" ;;
|
||||
216) echo "Custom: RootFS entry missing in config" ;;
|
||||
217) echo "Custom: Storage does not support rootdir" ;;
|
||||
220) echo "Custom: Unable to resolve template path" ;;
|
||||
222) echo "Custom: Template download failed after 3 attempts" ;;
|
||||
223) echo "Custom: Template not available after download" ;;
|
||||
231) echo "Custom: LXC stack upgrade/retry failed" ;;
|
||||
|
||||
# --- Default ---
|
||||
*) echo "Unknown error" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# SECTION 2: TELEMETRY FUNCTIONS
|
||||
|
||||
@ -1552,14 +1552,11 @@ advanced_settings() {
|
||||
# diagnostics_check()
|
||||
#
|
||||
# - Ensures diagnostics config file exists at /usr/local/community-scripts/diagnostics
|
||||
<<<<<<< Updated upstream
|
||||
# - Asks user whether to send anonymous diagnostic data
|
||||
# - Saves DIAGNOSTICS=yes/no in the config file
|
||||
=======
|
||||
# - Creates file if missing with default DIAGNOSTICS=yes
|
||||
# - Reads current diagnostics setting from file
|
||||
# - Sets global DIAGNOSTICS variable for API telemetry opt-in/out
|
||||
>>>>>>> Stashed changes
|
||||
# ------------------------------------------------------------------------------
|
||||
diagnostics_check() {
|
||||
if ! [ -d "/usr/local/community-scripts" ]; then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user