Exception: Rufus::Lua::LuaError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/rufus/lua/error.rb

Overview

An error class for rufus-lua.

Constant Summary collapse

CALLER_REX =
/^(.+):(\d+):/
DIR =
File.dirname(__FILE__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind, errcode, msg, bndng, filename, lineno) ⇒ LuaError

Returns a new instance of LuaError.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rufus/lua/error.rb', line 18

def initialize(kind, errcode, msg, bndng, filename, lineno)

  super("#{kind} : '#{msg}' (#{errcode} #{LUA_ERRS[errcode]})")

  @kind = kind
  @errcode = errcode
  @msg = msg

  @bndng = bndng
  @filename = filename
  @lineno = lineno
end

Instance Attribute Details

#bndngObject (readonly)

Returns the value of attribute bndng.



14
15
16
# File 'lib/rufus/lua/error.rb', line 14

def bndng
  @bndng
end

#errcodeObject (readonly)

Returns the value of attribute errcode.



13
14
15
# File 'lib/rufus/lua/error.rb', line 13

def errcode
  @errcode
end

#filenameObject (readonly)

Returns the value of attribute filename.



14
15
16
# File 'lib/rufus/lua/error.rb', line 14

def filename
  @filename
end

#kindObject (readonly)

Returns the value of attribute kind.



13
14
15
# File 'lib/rufus/lua/error.rb', line 13

def kind
  @kind
end

#linenoObject (readonly)

Returns the value of attribute lineno.



14
15
16
# File 'lib/rufus/lua/error.rb', line 14

def lineno
  @lineno
end

#msgObject (readonly)

Returns the value of attribute msg.



13
14
15
# File 'lib/rufus/lua/error.rb', line 13

def msg
  @msg
end

#original_backtraceObject (readonly)

Returns the value of attribute original_backtrace.



16
17
18
# File 'lib/rufus/lua/error.rb', line 16

def original_backtrace
  @original_backtrace
end

Instance Method Details

#set_backtrace(trace) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rufus/lua/error.rb', line 47

def set_backtrace(trace)

  @original_backtrace = trace

  trace =
    trace.select { |line|
      m = CALLER_REX.match(line)
      ( ! m) || File.dirname(m[1]) != DIR
    }

  trace.insert(0, "#{@filename}:#{@lineno}:") if @filename

  super(trace)
end