struct

Backtracer::Backtrace::Frame

Inherits Struct < Value < Object

An object representation of a stack frame.

Constructors

new(method : String, path : Nil | String = nil, lineno : Int32 | Nil = nil, column : Int32 | Nil = nil, *, configuration : Nil | Backtracer::Configuration = nil)
Source

Instance methods

==(other : self)
absolute_path

Returns:

  • path as is, if it's absolute - i.e. starts with /
  • path appended to configuration.src_path
  • nil otherwise

See Configuration#src_path

Source
column

The column number of this frame.

Source
context(context_lines : Int32 | Nil = nil) : Context | Nil

Returns Context record consisting of 3 elements - an array of context lines before the lineno, line at lineno, and an array of context lines after the lineno. In case of failure it returns nil.

Amount of returned context lines is taken from the context_lines argument if given, or configuration.context_lines otherwise.

NOTE: amount of returned context lines might be lower than given in cases where lineno is near the start or the end of the file.

See Configuration#context_lines

Source
hash(hasher)

See Object#hash(hasher)

in_app?

Returns true if this frame originated from the app source code, false otherwise.

See Configuration#app_dirs_pattern

Source
inspect(io : IO) : Nil

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Source
lineno

The line number of this frame.

Source
method

The method of this frame (such as User.find).

Source
path

The file name of this frame (such as app/models/user.cr).

Source
relative_path

Returns:

  • path as is, unless it's absolute - i.e. starts with /
  • path relative to configuration.src_path when under_src_path? is true
  • nil otherwise

NOTE: returned path is not required to be under_src_path? - see point no. 1

See Configuration#src_path

Source
shard_name

Returns name of the shard from which this frame originated.

See Configuration#modules_path_pattern

Source
to_s(io : IO) : Nil

Reconstructs the frame in a readable fashion.

Source
under_src_path?

Returns true if path of this frame is within the configuration.src_path, false otherwise.

See Configuration#src_path

Source

Nested types