Exception: Fluent::Win32Error
- Inherits:
-
StandardError
- Object
- StandardError
- Fluent::Win32Error
- Includes:
- Windows::Error
- Defined in:
- lib/fluent/plugin/file_wrapper.rb
Constant Summary collapse
- WSABASEERR =
10000
Instance Attribute Summary collapse
-
#errcode ⇒ Object
readonly
Returns the value of attribute errcode.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #format_english_message(errcode) ⇒ Object
-
#initialize(errcode, msg = nil) ⇒ Win32Error
constructor
A new instance of Win32Error.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #wsaerr? ⇒ Boolean
Constructor Details
#initialize(errcode, msg = nil) ⇒ Win32Error
Returns a new instance of Win32Error.
57 58 59 60 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 57 def initialize(errcode, msg = nil) @errcode = errcode @msg = msg end |
Instance Attribute Details
#errcode ⇒ Object (readonly)
Returns the value of attribute errcode.
53 54 55 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 53 def errcode @errcode end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
53 54 55 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 53 def msg @msg end |
Instance Method Details
#==(other) ⇒ Object
81 82 83 84 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 81 def ==(other) return false if other.class != Win32Error @errcode == other.errcode && @msg == other.msg end |
#format_english_message(errcode) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 62 def (errcode) buf = 0.chr * 260 flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY english_lang_id = 1033 # The result of MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US) FormatMessageA.call(flags, 0, errcode, english_lang_id, buf, buf.size, 0) buf.force_encoding(Encoding.default_external).strip end |
#inspect ⇒ Object
77 78 79 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 77 def inspect "#<#{to_s}>" end |
#to_s ⇒ Object
70 71 72 73 74 75 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 70 def to_s msg = super msg << ": code: #{@errcode}, #{(@errcode)}" msg << " - #{@msg}" if @msg msg end |
#wsaerr? ⇒ Boolean
86 87 88 |
# File 'lib/fluent/plugin/file_wrapper.rb', line 86 def wsaerr? @errcode >= WSABASEERR end |