Module: Telebugs::Backtrace::Patterns

Defined in:
lib/telebugs/backtrace.rb

Constant Summary collapse

RUBY =

The pattern that matches standard Ruby stack frames, such as ./spec/report_spec.rb:43:in ‘block (3 levels) in <top (required)>’

%r{\A
  (?<file>.+)       # Matches './spec/report_spec.rb'
  :
  (?<line>\d+)      # Matches '43'
  :in\s
  `(?<function>.*)' # Matches "`block (3 levels) in <top (required)>'"
\z}x
JAVA =

The pattern that matches JRuby Java stack frames, such as org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)

%r{\A
  (?<function>.+)  # Matches 'org.jruby.ast.NewlineNode.interpret'
  \(
    (?<file>
      (?:uri:classloader:/.+(?=:)) # Matches '/META-INF/jruby.home/protocol.rb'
      |
      (?:uri_3a_classloader_3a_.+(?=:)) # Matches 'uri_3a_classloader_3a_/gems/...'
      |
      [^:]+        # Matches 'NewlineNode.java'
    )
    :?
    (?<line>\d+)?  # Matches '105'
  \)
\z}x
GENERIC =

The pattern that tries to assume what a generic stack frame might look like, when exception’s backtrace is set manually.

%r{\A
  (?:from\s)?
  (?<file>.+)              # Matches '/foo/bar/baz.ext'
  :
  (?<line>\d+)?            # Matches '43' or nothing
  (?:
    in\s`(?<function>.+)'  # Matches "in `func'"
  |
    :in\s(?<function>.+)   # Matches ":in func"
  )?                       # ... or nothing
\z}x
OCI =
Note:

This is raised by github.com/kubo/ruby-oci8

The pattern that matches exceptions from PL/SQL such as ORA-06512: at “STORE.LI_LICENSES_PACK”, line 1945

/\A
  (?:
    ORA-\d{5}
    :\sat\s
    (?:"(?<function>.+)",\s)?
    line\s(?<line>\d+)
  |
    #{GENERIC}
  )
\z/x
EXECJS =

The pattern that matches CoffeeScript backtraces usually coming from Rails & ExecJS

/\A
  (?:
    # Matches 'compile ((execjs):6692:19)'
    (?<function>.+)\s\((?<file>.+):(?<line>\d+):\d+\)
  |
    # Matches 'bootstrap_node.js:467:3'
    (?<file>.+):(?<line>\d+):\d+(?<function>)
  |
    # Matches the Ruby part of the backtrace
    #{RUBY}
  )
\z/x