Module: Sqreen::Kit::StackTrace::Patterns

Defined in:
lib/sqreen/kit/signals/stack_trace.rb

Constant Summary collapse

RUBY =

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

Returns:

  • (Regexp)

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

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

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

Returns:

  • (Regexp)

    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 =

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

Returns:

  • (Regexp)

    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