Project

General

Profile

« Previous | Next » 

Revision 7c30a804

Added by Marc Dequènes over 14 years ago

  • ID 7c30a80459804cbfac2dfda5dae430b80b64331d

[fix] corrected crash due to exceptions returning non-tm

View differences:

lib/cyborghood/base/language.rb
alias :_orig :_
def _(message, parts = {})
create_tm(:_orig, message, parts)
create_tm(message, parts, :_orig)
end
alias :n_orig :n_
def n_(message, parts = {})
create_tm(:n_orig, message, parts)
create_tm(message, parts, :n_orig)
end
alias :s_orig :s_
def s_(message, parts = {})
create_tm(:s_orig, message, parts)
create_tm(message, parts, :s_orig)
end
alias :ns_orig :ns_
def ns_(message, parts = {})
create_tm(:ns_orig, message, parts)
create_tm(message, parts, :ns_orig)
end
alias :np_orig :np_
def np_(message, parts = {})
create_tm(:np_orig, message, parts)
create_tm(message, parts, :np_orig)
end
def create_tm(method, message, parts)
I18nMessage.new(self.send(method, message), message, parts)
def tm_(message, parts = {})
create_tm(message, parts)
end
def create_tm(message, parts, method = nil)
translated_message = (method.nil? ? message : self.send(method, message))
I18nMessage.new(translated_message, message, parts)
end
module_function :_, :n_, :s_, :ns_, :np_
lib/cyborghood/command_runner.rb
begin
execute_cmd(order.user, cmd.cmdsplit, order.shared_parameters, result)
rescue CyberError => e
result.message = e.message.capitalize + "."
result.message = tm_(e.message.capitalize + ".")
rescue
logger.error "Command crashed: " + $!
logger.error "Crash trace: " + $!.backtrace.join("\n")

Also available in: Unified diff