Module: Yuki::EXC
- Defined in:
- scripts/00100 Yuki__EXC.rb
Overview
Module that allows the game to write and Error.log file if the Exception is not a SystemExit or a Reset
Creation date : 2013, update : 26/09/2017
Constant Summary collapse
- Software =
Name of the current Game/Software
'Pokémon SDK'
Class Method Summary collapse
-
.build_error_log(e) ⇒ String
Method that build the error log.
-
.build_system_stack_error_log(e, str)
Build the SystemStackError message.
-
.dot_25_battle_reproduction(scene)
Function building the reproduction file.
-
.fix_source_path(source_name) ⇒ String
Function that corrects the source path.
-
.get_eval_script ⇒ String?
Get the eval script used by the current eval command.
-
.run(e, io = nil)
Method that runs #build_error_log if the Exception is not a SystemExit or a Reset.
-
.set_eval_script(script)
Sets the script used by the eval command.
-
.show_error_window(log)
Function that shows the error window.
Class Method Details
.build_error_log(e) ⇒ String
Method that build the error log.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'scripts/00100 Yuki__EXC.rb', line 44 def build_error_log(e) str = '' return build_system_stack_error_log(e, str) if e.is_a?(SystemStackError) return unless e.backtrace_locations source_arr = e.backtrace_locations[0] source_name = fix_source_path(source_arr.path.to_s) source_line = source_arr.lineno str << 'Erreur de script'.center(80, '=') # Formatage du message pour Windows str << format("\r\nMessage :\r\n%<message>s\r\n\r\n", message: e..to_s.sub(/#<([^ ]+).*>/, '#<\1>').gsub(/[\r\n]+/, "\r\n")) str << format("Type : %<type>s\r\n", type: e.class) str << format("Script : %<script>s\r\n", script: source_name) str << format("Ligne : %<line>d\r\n", line: source_line) str << format("Date : %<date>s\r\n", date: Time.new.strftime('%d/%m/%Y %H:%M:%S')) str << format("Game Version : %<game_version>s\r\n", game_version: Configs.infos.game_version) str << format("Logiciel : %<software>s %<version>s\r\n", software: Software, version: PSDK_Version.to_str_version) str << format("Script used by eval command : \r\n%<script>s\r\n\r\n", script: @eval_script) if @eval_script str << 'Backtraces'.center(80, '=') str << "\r\n" index = e.backtrace_locations.size e.backtrace_locations.each do |i| index -= 1 source_name = fix_source_path(i.path.to_s) str << format("[%<index>s] : %<script>s | ligne %<line>d %<method>s\r\n", index: index, script: source_name, line: i.lineno, method: i.base_label) end str << 'Fin du log'.center(80, '=') Yuki.set_clipboard(str) return str end |
.build_system_stack_error_log(e, str)
Build the SystemStackError message
106 107 108 109 110 111 112 113 114 115 |
# File 'scripts/00100 Yuki__EXC.rb', line 106 def build_system_stack_error_log(e, str) str << format("Message :\r\n%<message>s\r\n", message: e..to_s.gsub(/[\r\n]+/, "\r\n")) str << format("Type : %<type>s\r\n", type: e.class) str << format("Date : %<date>s\r\n", date: Time.new.strftime('%d/%m/%Y %H:%M:%S')) str << format("Game Version : %<game_version>s\r\n", game_version: Configs.infos.game_version) str << format("Logiciel : %<software>s %<version>s\r\n", software: Software, version: PSDK_Version.to_str_version) str << format("Script used by eval command : \r\n%<script>s\r\n", script: @eval_script) if @eval_script str << (e.backtrace || ['Unkown Sources...']).join("\r\n") return str end |
.dot_25_battle_reproduction(scene)
Function building the reproduction file
119 120 121 122 123 124 |
# File 'scripts/00100 Yuki__EXC.rb', line 119 def dot_25_battle_reproduction(scene) PFM.game_state.game_temp = Game_Temp.new $game_map.begin_save compressed_data = Zlib::Deflate.deflate(Marshal.dump([PFM.game_state, scene.battle_info]), Zlib::BEST_COMPRESSION) File.binwrite('battle.dat', compressed_data) end |
.fix_source_path(source_name) ⇒ String
Function that corrects the source path
79 80 81 82 83 84 85 |
# File 'scripts/00100 Yuki__EXC.rb', line 79 def fix_source_path(source_name) source = source_name.sub(File.('.'), nil.to_s).sub(File.(File.join(__FILE__, '../../..')), nil.to_s) unless source.sub!(%r{/pokemonsdk/scripts/(.*)}, '\1 (PSDK)') || source.sub!(%r{/scripts/(.*)}, '\1 (user)') source << (source.include?('/lib/') ? ' (ruby)' : ' (RMXP)') end return source end |
.get_eval_script ⇒ String?
Get the eval script used by the current eval command
99 100 101 |
# File 'scripts/00100 Yuki__EXC.rb', line 99 def get_eval_script return @eval_script end |
.run(e) .run(e, io)
Method that runs #build_error_log if the Exception is not a SystemExit or a Reset.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'scripts/00100 Yuki__EXC.rb', line 22 def run(e, io = nil) log_debug(e.inspect) return if e.class == LiteRGSS::DisplayWindow::ClosedWindowError raise if (e..empty? || e.class.to_s == 'Reset') && !e.is_a?(Interrupt) error_log = build_error_log(e) if io io << error_log else File.binwrite('Error.log', error_log) puts <<~EODSP The game crashed! The error is stored in Error.log. EODSP end dot_25_battle_reproduction($scene) if defined?(Battle::Scene) && $scene.is_a?(Battle::Scene) show_error_window(error_log) if $scene end |
.set_eval_script(script)
Sets the script used by the eval command
89 90 91 92 93 94 95 |
# File 'scripts/00100 Yuki__EXC.rb', line 89 def set_eval_script(script) if script @eval_script = script else @eval_script = nil end end |
.show_error_window(log)
Function that shows the error window
128 129 130 131 132 133 134 135 |
# File 'scripts/00100 Yuki__EXC.rb', line 128 def show_error_window(log) if defined?(GamePlay::Save) save_data = defined?(Battle::Scene) && $scene.is_a?(Battle::Scene) ? File.binread('battle.dat') : GamePlay::Save.save(nil, true) ErrorWindow.new.run(log, save_data) else ErrorWindow.new.run(log) end end |