The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Venus::Fault - Fault Class

ABSTRACT

Fault Class for Perl 5

SYNOPSIS

  package main;

  use Venus::Fault;

  my $fault = Venus::Fault->new;

  # $fault->throw;

DESCRIPTION

This package represents a generic system error (exception object).

METHODS

This package provides the following methods:

explain

  explain() (Str)

The explain method returns the error message and is used in stringification operations.

Since 1.80

explain example 1
  # given: synopsis;

  my $explain = $fault->explain;

  # "Exception! in ...

frames

  frames() (ArrayRef)

The frames method returns the compiled and stashed stack trace data.

Since 1.80

frames example 1
  # given: synopsis;

  my $frames = $fault->frames;

  # [
  #   ...
  #   [
  #     "main",
  #     "t/Venus_Fault.t",
  #     ...
  #   ],
  # ]

throw

  throw(Str $message) (Fault)

The throw method throws an error if the invocant is an object, or creates an error object using the arguments provided and throws the created object.

Since 1.80

throw example 1
  # given: synopsis;

  my $throw = $fault->throw;

  # bless({ ... }, 'Venus::Fault')

trace

  trace(Int $offset, Int $limit) (Fault)

The trace method compiles a stack trace and returns the object. By default it skips the first frame.

Since 1.80

trace example 1
  # given: synopsis;

  my $trace = $fault->trace;

  # bless({ ... }, 'Venus::Fault')
trace example 2
  # given: synopsis;

  my $trace = $fault->trace(0, 1);

  # bless({ ... }, 'Venus::Fault')
trace example 3
  # given: synopsis;

  my $trace = $fault->trace(0, 2);

  # bless({ ... }, 'Venus::Fault')

OPERATORS

This package overloads the following operators:

operation: (eq)

This package overloads the eq operator.

example 1

  # given: synopsis;

  my $result = $fault eq 'Exception!';

  # 1
operation: (ne)

This package overloads the ne operator.

example 1

  # given: synopsis;

  my $result = $fault ne 'exception!';

  # 1
operation: (qr)

This package overloads the qr operator.

example 1

  # given: synopsis;

  my $test = 'Exception!' =~ qr/$fault/;

  # 1
operation: ("")

This package overloads the "" operator.

example 1

  # given: synopsis;

  my $result = "$fault";

  # "Exception!"
operation: (~~)

This package overloads the ~~ operator.

example 1

  # given: synopsis;

  my $result = $fault ~~ 'Exception!';

  # 1

AUTHORS

Awncorp, awncorp@cpan.org

LICENSE

Copyright (C) 2000, Al Newkirk.

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.