mirror of
https://github.com/JonasunderscoreJones/dayz-linux-gui-launcher.git
synced 2025-10-23 00:09:19 +02:00
fix: API response error handling
This commit is contained in:
parent
1a947d3d76
commit
7cd36d34fe
1 changed files with 4 additions and 1 deletions
|
@ -13,6 +13,7 @@ DIR_DAYZ="${STEAM_ROOT}/common/DayZ"
|
|||
API_URL="https://api.daemonforge.dev/server/@ADDRESS@/@PORT@/full"
|
||||
API_PARAMS=(
|
||||
-sSL
|
||||
-m 10
|
||||
-H "Referer: https://daemonforge.dev/"
|
||||
-H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
|
||||
)
|
||||
|
@ -89,7 +90,9 @@ if [[ -n "${SERVER}" ]]; then
|
|||
msg "Querying API for server: ${SERVER%:*}:${PORT}"
|
||||
query="$(sed -e "s/@ADDRESS@/${SERVER%:*}/" -e "s/@PORT@/${PORT}/" <<< "${API_URL}")"
|
||||
debug "Querying ${query}"
|
||||
response="$(curl "${API_PARAMS[@]}" "${query}")"
|
||||
response="$(curl "${API_PARAMS[@]}" "${query}" || err "Error while querying API")"
|
||||
debug "Parsing API response"
|
||||
jq -e ".mods[]" 2>&1 >/dev/null <<< "${response}" || err "Missing mods data from API response"
|
||||
INPUT+=( $(jq -r ".mods[] | select(.app_id == ${DAYZ_ID}) | .id" <<< "${response}") )
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue