Print message on YML syntax error
authorriking <rikingcoding@gmail.com>
Fri, 6 Jun 2014 20:33:21 +0000 (13:33 -0700)
committerriking <rikingcoding@gmail.com>
Fri, 6 Jun 2014 20:47:11 +0000 (13:47 -0700)
launcher

index cd9ccbd3a1c0614e048816882e2ccbf1b44c2d68..841e3a4f8f57d0a4e9924ca794536234b444edcb 100755 (executable)
--- a/launcher
+++ b/launcher
@@ -185,6 +185,9 @@ set_template_info() {
        yml.strip!
        begin
          env.merge!(YAML.load(yml)['env'] || {})
+       rescue Psych::SyntaxError => e
+        puts e
+        puts "*ERROR."
        rescue => e
         puts yml
         p e
@@ -196,12 +199,20 @@ RUBY
     raw=`exec echo "$input" | $docker_path run --rm -i -a stdin -a stdout $image ruby -e "$env_ruby"`
 
     env=()
+    ok=1
     while read i; do
-      if [ -n "$i" ]; then
+      if [ "$i" == "*ERROR." ]; then
+        ok=0
+      elif [ -n "$i" ]; then
         env[${#env[@]}]=$i
       fi
     done <<< "$raw"
 
+    if [ "$ok" -ne 1 ]; then
+      echo "${env[@]}"
+      echo "YAML syntax error. Please check your configuration files."
+      exit 1
+    fi
     echo "Calculated ENV: ${env[@]}"
 }