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.
Initialize the MessageHandler. console specifies if the messages should be printed to $stderr.
# File lib/taskjuggler/MessageHandler.rb, line 94 94: def initialize(console = false) 95: @messages = [] 96: @console = console 97: # We count the errors. 98: @errors = 0 99: end
Generate a message by specifying the type.
# File lib/taskjuggler/MessageHandler.rb, line 138 138: def addMessage(type, id, message, sourceFileInfo = nil, line = nil, 139: data = nil, scenario = nil) 140: abortOnError = type == :error 141: # Treat criticals like errors but without generating another 142: # exception. 143: type = :error if type == :critical 144: 145: msg = Message.new(type, id, message, sourceFileInfo, line, data, scenario) 146: @messages << msg 147: # Print the message to $stderr if requested by the user. 148: $stderr.puts msg.to_s if @console 149: 150: case type 151: when :error 152: # Increase the error counter. 153: @errors += 1 154: raise TjException.new, '' if abortOnError 155: when :fatal 156: raise RuntimeError 157: end 158: end
Generate an critical message.
# File lib/taskjuggler/MessageHandler.rb, line 114 114: def critical(id, message, sourceFileInfo = nil, line = nil, data = nil, 115: scenario = nil) 116: addMessage(:critical, id, message, sourceFileInfo, line, data, scenario) 117: end
Generate a debug message.
# File lib/taskjuggler/MessageHandler.rb, line 132 132: def debug(id, message, sourceFileInfo = nil, line = nil, data = nil, 133: scenario = nil) 134: addMessage(:info, id, message, sourceFileInfo, line, data, scenario) 135: end
Generate an error message.
# File lib/taskjuggler/MessageHandler.rb, line 108 108: def error(id, message, sourceFileInfo = nil, line = nil, data = nil, 109: scenario = nil) 110: addMessage(:error, id, message, sourceFileInfo, line, data, scenario) 111: end
Generate a fatal message that will abort the application.
# File lib/taskjuggler/MessageHandler.rb, line 102 102: def fatal(id, message, sourceFileInfo = nil, line = nil, data = nil, 103: scenario = nil) 104: addMessage(:fatal, id, message, sourceFileInfo, line, data, scenario) 105: end
Generate an info message.
# File lib/taskjuggler/MessageHandler.rb, line 126 126: def info(id, message, sourceFileInfo = nil, line = nil, data = nil, 127: scenario = nil) 128: addMessage(:info, id, message, sourceFileInfo, line, data, scenario) 129: end
Convert all messages into a single String.
# File lib/taskjuggler/MessageHandler.rb, line 161 161: def to_s 162: text = '' 163: @messages.each { |msg| text += msg.to_s } 164: text 165: end
Generate a warning.
# File lib/taskjuggler/MessageHandler.rb, line 120 120: def warning(id, message, sourceFileInfo = nil, line = nil, data = nil, 121: scenario = nil) 122: addMessage(:warning, id, message, sourceFileInfo, line, data, scenario) 123: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.