curl trap
This commit is contained in:
		
							parent
							
								
									e068565062
								
							
						
					
					
						commit
						ab8eb90c92
					
				| @ -928,3 +928,43 @@ function setup_gs() { | ||||
|     msg_error "Ghostscript installation failed" | ||||
|   fi | ||||
| } | ||||
| 
 | ||||
| enable_curl_strict_error_handling() { | ||||
|   set -eE -o pipefail | ||||
|   trap '__curl_err_handler $?' ERR | ||||
| } | ||||
| 
 | ||||
| __curl_err_handler() { | ||||
|   local exit_code="$1" | ||||
|   local cmd="${BASH_COMMAND:-unknown}" | ||||
|   if [[ "$cmd" != curl* ]]; then | ||||
|     return | ||||
|   fi | ||||
| 
 | ||||
|   case $exit_code in | ||||
|   1) msg_error "Unsupported protocol in: $cmd" ;; | ||||
|   2) msg_error "Failed curl initialization in: $cmd" ;; | ||||
|   3) msg_error "Malformed URL in: $cmd" ;; | ||||
|   5) msg_error "Could not resolve proxy in: $cmd" ;; | ||||
|   6) msg_error "Could not resolve host in: $cmd" ;; | ||||
|   7) msg_error "Failed to connect to host in: $cmd" ;; | ||||
|   9) msg_error "Access denied to remote resource in: $cmd" ;; | ||||
|   18) msg_error "Partial file transfer detected in: $cmd" ;; | ||||
|   22) msg_error "HTTP error response in: $cmd" ;; | ||||
|   23) msg_error "Write error during transfer in: $cmd" ;; | ||||
|   26) msg_error "Read error from local file in: $cmd" ;; | ||||
|   28) msg_error "Operation timed out in: $cmd" ;; | ||||
|   35) msg_error "SSL connect error in: $cmd" ;; | ||||
|   47) msg_error "Too many redirects in: $cmd" ;; | ||||
|   51) msg_error "SSL certificate verification failed in: $cmd" ;; | ||||
|   52) msg_error "Empty response from server in: $cmd" ;; | ||||
|   55) msg_error "Send error during transfer in: $cmd" ;; | ||||
|   56) msg_error "Receive error during transfer in: $cmd" ;; | ||||
|   60) msg_error "SSL CA certificate not trusted in: $cmd" ;; | ||||
|   67) msg_error "Login denied by server in: $cmd" ;; | ||||
|   78) msg_error "Remote file not found (404) in: $cmd" ;; | ||||
|   *) msg_error "Unhandled curl error (exit $exit_code) in: $cmd" ;; | ||||
|   esac | ||||
| 
 | ||||
|   exit_script | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 CanbiZ
						CanbiZ