Exception: StandardError

Inherits:
Exception
  • Object
show all
Defined in:
lib/ass_ole/core_patch/standard_error.rb

Overview

Monkey patch for encoding error message

Direct Known Subclasses

AssOle::Snippets::ContextError

Class Method Summary collapse

Class Method Details

.__patch_message__Object



3
4
5
6
7
8
9
10
# File 'lib/ass_ole/core_patch/standard_error.rb', line 3

def self.__patch_message__
  old_message = instance_method(:message)
  define_method(:message) do
    old_message.bind(self).call.force_encoding('ASCII-8BIT')\
      .split(%r{(HRESULT error code:\dx\d+)}i)[0 .. 1].join
      .force_encoding('UTF-8').strip
  end
end