Commits

Brian Mearns committed 65b8f3b

Added try-except for unicode errors, and fixed a little bug in error message printing.

Comments (0)

Files changed (1)

             # the parser as TEXT.
             elif stmt in (STMT_TEXT, STMT_CEMBED) :
                 assert(isinstance(value, (str, unicode))), type(value)
-                ostream.write(value.encode("utf-8"))
+                try:
+                    ostream.write(value.encode("utf-8"))
+                except UnicodeDecodeError, e:
+                    raise texceptions.TemplateException(str(e), filepos)
 
             elif stmt == STMT_LIST:
                 #Evaluate it.
         if debug:
             raise
         raise TemplateProcessingError(e, e.filepos)
+        
 
 
 
 
         elif arg in ("-s", "--set"):
             if i == argc:
-                sys.stderr.write("%s: Error: Missing required parameter for option %d.\n" % (sys.argv[0], arg))
+                sys.stderr.write("%s: Error: Missing required parameter for option %s.\n" % (sys.argv[0], arg))
                 sys.stderr.write("%s: Try `%s --help`\n" % (sys.argv[0], sys.argv[0]))
                 return (errno.EINVAL)
             else: