Skip to content

Commit 855ae67

Browse files
committed
Updated exit codes with clearer message.
1 parent 6f116f0 commit 855ae67

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

action.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,16 @@ runs:
290290
FAILED=false
291291
292292
# Run Gemini CLI with the provided prompt, streaming responses in debug
293+
EXIT_CODE=0
293294
if [[ "${DEBUG}" = true ]]; then
294295
echo "::warning::Gemini CLI debug logging is enabled. This will stream responses, which could reveal sensitive information if processed with untrusted inputs."
295296
if ! { gemini --yolo --prompt "${PROMPT}" 2> >(tee "${TEMP_STDERR}" >&2) | tee "${TEMP_STDOUT}"; }; then
297+
EXIT_CODE=$?
296298
FAILED=true
297299
fi
298300
else
299301
if ! gemini --yolo --prompt "${PROMPT}" 2> "${TEMP_STDERR}" 1> "${TEMP_STDOUT}"; then
302+
EXIT_CODE=$?
300303
FAILED=true
301304
fi
302305
fi
@@ -323,10 +326,39 @@ runs:
323326
echo "EOF" >> "${GITHUB_OUTPUT}"
324327
325328
if [[ "${FAILED}" = true ]]; then
329+
case "${EXIT_CODE}" in
330+
1)
331+
MSG="General error"
332+
;;
333+
41)
334+
MSG="Authentication failure. Please check your credentials (API key or Google Cloud auth)."
335+
;;
336+
42)
337+
MSG="Invalid input or configuration. Please check your prompt or CLI arguments."
338+
;;
339+
52)
340+
MSG="Configuration error. Failed to save settings."
341+
;;
342+
53)
343+
MSG="Turn limit exceeded. The conversation has reached its maximum length."
344+
;;
345+
126)
346+
MSG="Command invoked cannot execute"
347+
;;
348+
127)
349+
MSG="Command not found"
350+
;;
351+
130)
352+
MSG="User cancelled. The operation was interrupted."
353+
;;
354+
*)
355+
MSG="Unknown error (exit code: ${EXIT_CODE})"
356+
esac
357+
326358
LAST_LINE="$(tail -n1 "${TEMP_STDERR}")"
327-
echo "::error title=Gemini CLI execution failed::${LAST_LINE}"
359+
printf "::error title=Gemini CLI execution failed (%%s)::%%s\n" "${MSG}" "${LAST_LINE}"
328360
echo "See logs for more details"
329-
exit 1
361+
exit "${EXIT_CODE}"
330362
fi
331363
env:
332364
DEBUG: '${{ fromJSON(inputs.gemini_debug || false) }}'

0 commit comments

Comments
 (0)