Skip to content

Commit

Permalink
lto2filemaker: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dericed committed Oct 16, 2015
1 parent d660388 commit ab35aaf
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lto2filemaker
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ while read TAPE ; do
TAPE_ID=$(echo "${TAPE}" | grep -o "name=[^ ]*" | sed 's/"//g')
_report -d "Uploading tape metadata for tape "${TAPE_ID}". Please wait…"
eval "${TAPE_CMD}"
ERROR_CODE=$(xml sel -t -m /_:fmresultset/_:error -v @code "${CURL_OUTPUT}" 2>/dev/null)
if [[ "${ERROR_CODE}" == 404 ]] ; then
_report -d "The database is not responding."
elif [[ "${ERROR_CODE}" == 504 ]] ; then
_report -d "The database already knows about: ${SCHEMA_NAME}"
elif [[ -z "${ERROR_CODE}" ]] ; then
_report -d "There is an error in uploading ${SCHEMA_NAME}:"
cat "${CURL_OUTPUT}"
elif [[ "${ERROR_CODE}" != 0 ]] ; then
_report -d "Warning error code ${ERROR_CODE} from database while uploading the tape record of ${SCHEMA_NAME}."
fi
fi
done < "${LTO_TAPE_TMP}"
_report -d "Uploading file metadata for tape "${TAPE_ID}". Please wait…"
Expand All @@ -66,6 +77,18 @@ while read FILE ; do
FILE_CMD="curl ${CURL_OPTS[@]} -G "${FILE}" \"http://${FILEMAKER_XML_URL}?-db=${FILEMAKER_DB}&-lay=lto_files&-new\" ${REDIRECT}"
FILE_ID=$(echo "${FILE}" | grep -o "name=[^ ]*" | sed 's/"//g')
eval "${FILE_CMD}"
ERROR_CODE=$(xml sel -t -m /_:fmresultset/_:error -v @code "${CURL_OUTPUT}" 2>/dev/null)
if [[ "${ERROR_CODE}" == 404 ]] ; then
_report -w "The database is not responding."
elif [[ "${ERROR_CODE}" == 504 ]] ; then
_report -d "The database already knows about a file in ${SCHEMA_NAME} called $FILE_ID"
elif [[ -z "${ERROR_CODE}" ]] ; then
_report -d "There is an error in uploading ${SCHEMA_NAME}:"
cat "${CURL_OUTPUT}"
echo
elif [[ "${ERROR_CODE}" != 0 ]] ; then
_report -w "Warning error code ${ERROR_CODE} from database while uploading a file record of ${SCHEMA_NAME}."
fi
fi
done < "${LTO_FILE_TMP}"
_report -d "Done uploading metadata for ${TAPE_ID}."

0 comments on commit ab35aaf

Please sign in to comment.