struct Backtracer::Backtrace::Frame

Overview

An object representation of a stack frame.

Defined in:

backtracer/backtrace/frame.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(method : String, path : Nil | String = nil, lineno : Int32 | Nil = nil, column : Int32 | Nil = nil, *, configuration : Nil | Backtracer::Configuration = nil) #

[View source]

Instance Method Detail

def ==(other : self) #

def absolute_path : String | Nil #

Returns:

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

See Configuration#src_path


[View source]
def column : Int32 | Nil #

The column number of this frame.


[View source]
def context(context_lines : Int32 | Nil = nil) : Tuple(Array(String), String, Array(String)) | Nil #

Returns a tuple 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.

See Configuration#context_lines


[View source]
def context_hash(context_lines : Int32 | Nil = nil) : Hash(Int32, String) | Nil #

Returns hash with context lines, where line numbers are keys and the lines itself are values. 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.

See Configuration#context, Configuration#context_lines


[View source]
def hash(hasher) #
Description copied from struct Struct

See Object#hash(hasher)


def in_app? : Bool #

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

See Configuration#app_dirs_pattern


[View source]
def inspect(io : IO) : Nil #
Description copied from struct Struct

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)"

[View source]
def lineno : Int32 | Nil #

The line number of this frame.


[View source]
def method : String #

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


[View source]
def path : String | Nil #

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


[View source]
def relative_path : String | Nil #

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


[View source]
def shard_name : String | Nil #

Returns name of the shard from which this frame originated.

See Configuration#modules_path_pattern


[View source]
def to_s(io : IO) : Nil #

Reconstructs the frame in a readable fashion.


[View source]
def under_src_path? : Bool #

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

See Configuration#src_path


[View source]