| Class | TaskJuggler::MessageHandler |
| In: |
lib/taskjuggler/MessageHandler.rb
|
| Parent: | Object |
The MessageHandler can display and store application messages. Depending on the type of the message, a TjExeption can be raised (:error), or the program can be immedidately aborted (:fatal). Other types will just continue the program flow.
| abortOnWarning | [RW] | |
| errors | [R] | |
| messages | [R] | |
| scenario | [RW] |
Initialize the MessageHandler. console specifies if the messages should be printed to $stderr.
# File lib/taskjuggler/MessageHandler.rb, line 103 def initialize(console = false) @messages = [] @console = console # We count the errors. @errors = 0 # Set to true if program should be exited on warnings. @abortOnWarning = false end
Generate a message by specifying the type.
# File lib/taskjuggler/MessageHandler.rb, line 149 def addMessage(type, id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) # Treat criticals like errors but without generating another # exception. msg = Message.new(type == :critical ? :error : type, id, message, sourceFileInfo, line, data, scenario) @messages << msg # Print the message to $stderr if requested by the user. $stderr.puts msg.to_s if @console case type when :warning raise TjException.new, '' if @abortOnWarning when :critical # Increase the error counter. @errors += 1 when :error # Increase the error counter. @errors += 1 raise TjException.new, '' when :fatal raise RuntimeError end end