diff --git a/bin/http_xsltproc.sh b/bin/http_xsltproc.sh index 414e18a..091b6f9 100755 --- a/bin/http_xsltproc.sh +++ b/bin/http_xsltproc.sh @@ -182,8 +182,8 @@ if [ ! -d "$CACHE_DIR" ]; then /bin/mkdir "$CACHE_DIR" exit_code=$? if [ $exit_code -ne 0 ]; then - echo "ERROR: $script_name failed to create dir: $CACHE_DIR" >&2 - exit $exit_code + echo "ERROR: $script_name failed to create dir $CACHE_DIR (exit code: $exit_code)" >&2 + exit 2 fi fi $verbose_mode && printf "$script_name using cache directory: %s\n" "$CACHE_DIR" @@ -210,8 +210,8 @@ for lib_filename in $LIB_FILENAMES; do source "$lib_file" >&2 exit_code=$? if [ $exit_code -ne 0 ]; then - echo "ERROR: $script_name failed to source script $lib_file" >&2 - exit $exit_code + echo "ERROR: $script_name failed to source script $lib_file (exit code: $exit_code)" >&2 + exit 2 fi done @@ -233,10 +233,10 @@ else fi if [ ! -d "$TMP_DIR" ]; then /bin/mkdir "$TMP_DIR" - exit_status=$? - if [ $exit_status -ne 0 ]; then - echo "ERROR: $script_name failed to create dir: $TMP_DIR" >&2 - exit $exit_status + exit_code=$? + if [ $exit_code -ne 0 ]; then + echo "ERROR: $script_name failed to create dir $TMP_DIR (exit code: $exit_code)" >&2 + exit 2 fi fi @@ -253,8 +253,10 @@ $verbose_mode && printf "$script_name requesting resource: %s\n" "$xml_location" conditional_get $local_opts -d "$CACHE_DIR" -t "$TMP_DIR" "$xml_location" > "$xml_file" exit_code=$? if [ $exit_code -ne 0 ]; then - echo "ERROR: $script_name failed to get resource: $location" >&2 - printf "See output log: %s\n" "$TMP_DIR/$conditional_get_log" >&2 + if [ $exit_code -gt 1 ]; then + echo "ERROR: $script_name failed to get resource: $location" >&2 + printf "See output log: %s\n" "$TMP_DIR/$conditional_get_log" >&2 + fi exit $exit_code fi $verbose_mode && printf "$script_name successfully obtained XML file: %s\n" "$xml_file" @@ -265,7 +267,7 @@ $verbose_mode && printf "$script_name writing xsltproc output to file: %s\n" "$x exit_code=$? if [ $exit_code -ne 0 ]; then echo "ERROR: ${script_name}: xsltproc failed with status code: $exit_code" >&2 - exit $exit_code + exit 3 fi $verbose_mode && printf "$script_name successfully executed xsltproc\n" @@ -273,16 +275,16 @@ if [ -z "$out_file" ]; then /bin/cat "$xsltproc_out_file" exit_code=$? if [ $exit_code -ne 0 ]; then - echo "ERROR: ${script_name} unable to cat output to stdout" >&2 - exit $exit_code + echo "ERROR: ${script_name} unable to cat output with status code: $exit_code" >&2 + exit 3 fi else $verbose_mode && printf "$script_name writing output to file: %s\n" "$out_file" /bin/cp "$xsltproc_out_file" "$out_file" exit_code=$? if [ $exit_code -ne 0 ]; then - echo "ERROR: ${script_name} unable to copy output to file: $out_file" >&2 - exit $exit_code + echo "ERROR: ${script_name} unable to copy output to file $out_file (exit code: $exit_code)" >&2 + exit 3 fi fi