Devel::...Extract(3)

πŸ“¦
version 1.000000 Β· 4 versions
, in epel 9

πŸ¦‹ Devel::StackTrace::Extract πŸ¦‹

okay so bestie, welcome to this User Contributed Perl Documentation page β€” page tag Devel::...Extract(3), and the vibe is making stack-trace extraction from exception objects make sense πŸ’…

✨ NAME ✨

Devel::StackTrace::Extract β€” Extract a stack trace from an exception object

πŸŽ€ VERSION πŸŽ€

version 1.000000

🌸 DESCRIPTION 🌸

okay so storing stack traces inside objects that get thrown as exceptions? Super popular, no cap. But this being Perl, there’s more than one way to do it 😭. This module gives you a simple interface that attempts to extract the stack trace from various well-known exception classes that are on the CPAN. It’s giving β€œone little helper, many exception flavors” 🫢.

🫢 FUNCTION 🫢

Exported on demand or can be used fully qualified.

πŸ’– extract_stack_trace($exception_object) πŸ’–

Returns a Devel::StackTrace stack trace object extracted from the exception object, or returns undef if no stack trace can be extracted with the current heuristics.

The current rules that this uses to determine how to get a stack trace are, in order, as follows (these are subject to change without notice):

  1. If it has a method called stack_trace, use that β€” This works with anything that uses the StackTrace::Auto Moose/Moo role, or subclasses the Throwable::Exception class.
  2. If it is a Mojo::Exception, and has a method called frames, use that β€” If we have a modern Mojo::Exception object with a frames method, and it has its frames populated (i.e. someone used the trace method, or called throw), then we’ll synthesize a Devel::StackTrace instance from that.
  3. If it has a trace method, call that β€” This works for Exception::Class built exception objects, as well as any Moose::Exception instances.

πŸ’€ BUGS πŸ’€

  • The heuristics in this make no attempt to check whatever is returned by the exception classes are valid Devel::StackTrace objects.
  • Mojo::Exception objects don’t keep track of the arguments that are passed to a stack frame, so the Devel::StackTrace that this synthesizes acts as if every subroutine was called without arguments.

πŸ‘€ SEE ALSO πŸ‘€

  • Devel::StackTrace
  • Throwable::Error and StackTrace::Auto
  • Exception::Class
  • Moose::Exception
  • Mojo::Exception

πŸ‘‘ AUTHOR πŸ‘‘

Mark Fowler <mfowler@maxmind.com>

πŸ«‚ CONTRIBUTORS πŸ«‚

  • Dave Rolsky <drolsky@maxmind.com>
  • Mark Fowler <mark@twoshortplanks.com>
  • Olaf Alders <oalders@maxmind.com>

This software is copyright (c) 2016 by MaxMind, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


later bestie 🫢✨ β€” signing off from perl v5.32.1, dated 2025-01-18, with the page tag Devel::...Extract(3) πŸ’–

πŸ“¦ where this page comes from