enhance error logging
This commit is contained in:
parent
496a7ff8f3
commit
21462dcbc8
1 changed files with 8 additions and 5 deletions
13
strm
13
strm
|
|
@ -18,6 +18,10 @@ function print_usage {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function error {
|
||||||
|
echo "ERROR: $1" >&2
|
||||||
|
}
|
||||||
|
|
||||||
# Check if mpv is installed
|
# Check if mpv is installed
|
||||||
if ! command -v mpv &>/dev/null
|
if ! command -v mpv &>/dev/null
|
||||||
then
|
then
|
||||||
|
|
@ -39,7 +43,7 @@ while (( "$#" )); do
|
||||||
config="$2"
|
config="$2"
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
echo "Argument for $1 is missing"
|
error "Argument for $1 is missing"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
@ -65,19 +69,18 @@ done
|
||||||
if test -f "$config"; then
|
if test -f "$config"; then
|
||||||
. "$config"
|
. "$config"
|
||||||
else
|
else
|
||||||
echo "Config file not found ($config)"
|
error "Config file not found ($config)"
|
||||||
echo "Please create it or set one with the --config flag"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check validity of variables
|
# Check validity of variables
|
||||||
config_valid=true
|
config_valid=true
|
||||||
if [ "$connection_string" == "" ]; then
|
if [ "$connection_string" == "" ]; then
|
||||||
echo "Connection string is missing"
|
error "Connection string is missing"
|
||||||
config_valid=false
|
config_valid=false
|
||||||
fi
|
fi
|
||||||
if [ "$media_directory" == "" ]; then
|
if [ "$media_directory" == "" ]; then
|
||||||
echo "Media directory is missing"
|
error "Media directory is missing"
|
||||||
config_valid=false
|
config_valid=false
|
||||||
else
|
else
|
||||||
# Check if media directory has trailing slash and add it if missing
|
# Check if media directory has trailing slash and add it if missing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue