fixing throwing an error string in the Rewriter, when it should have been an Error object

This commit is contained in:
Jeremy Ashkenas 2010-02-23 21:59:29 -05:00
parent 7de4caffca
commit 4d146bacb1
3 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ get '/hello', ->
# Append. # Append.
append: (location, data) -> append: (location, data) ->
path: new Pathname location path: new Pathname location
throw "Location does not exist" unless path.exists() throw new Error("Location does not exist") unless path.exists()
File.open path, 'a', (file) -> File.open path, 'a', (file) ->
file.puts YAML.dump data file.puts YAML.dump data

View File

@ -295,7 +295,7 @@
levels[open] -= 1; levels[open] -= 1;
} }
if (levels[open] < 0) { if (levels[open] < 0) {
throw "too many " + token[1]; throw new Error("too many " + token[1]);
} }
} }
return 1; return 1;

View File

@ -199,7 +199,7 @@ re::ensure_balance: (pairs) ->
levels[open] ||= 0 levels[open] ||= 0
levels[open] += 1 if token[0] is open levels[open] += 1 if token[0] is open
levels[open] -= 1 if token[0] is close levels[open] -= 1 if token[0] is close
throw "too many " + token[1] if levels[open] < 0 throw new Error("too many " + token[1]) if levels[open] < 0
return 1 return 1
unclosed: key for key, value of levels when value > 0 unclosed: key for key, value of levels when value > 0
throw new Error("unclosed " + unclosed[0]) if unclosed.length throw new Error("unclosed " + unclosed[0]) if unclosed.length