Skip to main content

get_exception_context

Function get_exception_context 

Source
pub fn get_exception_context(name: &str) -> Option<ExceptionContext>
Expand description

Get exception context for upgrade suggestions and error variables.

Returns metadata about exception handling semantics:

  • error_variable: special variable capturing the exception ($@)
  • preferred_alternative: recommended upgrade path (dieCarp::croak)

Returns None for non-exception functions (e.g. eval, print).

§Examples

use perl_semantic_analyzer::analysis::semantic::get_exception_context;

let die_ctx = get_exception_context("die").unwrap();
assert_eq!(die_ctx.error_variable, Some("$@".to_string()));
assert_eq!(die_ctx.preferred_alternative, Some("Carp::croak".to_string()));

let croak_ctx = get_exception_context("croak").unwrap();
assert_eq!(croak_ctx.preferred_alternative, None);  // already preferred