Flash red when entering a malformed command in the command panel

This commit is contained in:
Nathan Sobo
2012-03-28 16:11:44 -07:00
parent e0ed462c6e
commit a4c25dc678
3 changed files with 30 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
{View} = require 'space-pen'
CommandInterpreter = require 'command-interpreter'
Editor = require 'editor'
{SyntaxError} = require('pegjs').parser
module.exports =
class CommandPanel extends View
@@ -41,7 +42,17 @@ class CommandPanel extends View
@rootView.activeEditor().focus()
execute: ->
@commandInterpreter.eval(@rootView.activeEditor(), @editor.getText())
try
@commandInterpreter.eval(@rootView.activeEditor(), @editor.getText())
catch error
if error instanceof SyntaxError
@addClass 'error'
removeErrorClass = => @removeClass 'error'
window.setTimeout(removeErrorClass, 200)
return
else
throw error
@hide()
repeatRelativeAddress: ->