GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Venus::Throw(3) User Contributed Perl Documentation Venus::Throw(3)

Venus::Throw - Throw Class

Throw Class for Perl 5

  package main;
  use Venus::Throw;
  my $throw = Venus::Throw->new;
  # $throw->error;

This package provides a mechanism for generating and raising errors (exception objects).

This package has the following attributes:

  frame(Int)

This attribute is read-write, accepts "(Int)" values, and is optional.

  name(Str)

This attribute is read-write, accepts "(Str)" values, and is optional.

  message(Str)

This attribute is read-write, accepts "(Str)" values, and is optional.

  package(Str)

This attribute is read-only, accepts "(Str)" values, and is optional.

  parent(Str)

This attribute is read-only, accepts "(Str)" values, is optional, and defaults to 'Venus::Error'.

  context(Str)

This attribute is read-only, accepts "(Str)" values, and is optional.

This package inherits behaviors from:

Venus::Kind::Utility

This package integrates behaviors from:

Venus::Role::Stashable

This package provides the following methods:

  as(string $name) (Venus::Throw)

The as method sets a "name" for the error and returns the invocant.

Since 2.55

as example 1
  # given: synopsis
  package main;
  $throw = $throw->as('on.handler');
  # bless({...}, 'Venus::Throw')
    

  error(hashref $data) (Venus::Error)

The error method throws the prepared error object.

Since 0.01

error example 1
  # given: synopsis;
  my $error = $throw->error;
  # bless({
  #   ...,
  #   "context"  => "(eval)",
  #   "message"  => "Exception!",
  # }, "Main::Error")
    
error example 2
  # given: synopsis;
  my $error = $throw->error({
    message => 'Something failed!',
    context => 'Test.error',
  });
  # bless({
  #   ...,
  #   "context"  => "Test.error",
  #   "message"  => "Something failed!",
  # }, "Main::Error")
    
error example 3
  package main;
  use Venus::Throw;
  my $throw = Venus::Throw->new('Example::Error');
  my $error = $throw->error;
  # bless({
  #   ...,
  #   "context"  => "(eval)",
  #   "message"  => "Exception!",
  # }, "Example::Error")
    
error example 4
  package main;
  use Venus::Throw;
  my $throw = Venus::Throw->new(
    package => 'Example::Error',
    parent => 'Venus::Error',
  );
  my $error = $throw->error({
    message => 'Example error!',
  });
  # bless({
  #   ...,
  #   "context"  => "(eval)",
  #   "message"  => "Example error!",
  # }, "Example::Error")
    
error example 5
  package Example::Error;
  use base 'Venus::Error';
  package main;
  use Venus::Throw;
  my $throw = Venus::Throw->new(
    package => 'Example::Error::Unknown',
    parent => 'Example::Error',
  );
  my $error = $throw->error({
    message => 'Example error (unknown)!',
  });
  # bless({
  #   ...,
  #   "context"  => "(eval)",
  #   "message"  => "Example error (unknown)!",
  # }, "Example::Error::Unknown")
    
error example 6
  package main;
  use Venus::Throw;
  my $throw = Venus::Throw->new(
    package => 'Example::Error::NoThing',
    parent => 'No::Thing',
  );
  my $error = $throw->error({
    message => 'Example error (no thing)!',
  });
  # No::Thing does not exist
  # Exception! Venus::Throw::Error (isa Venus::Error)
    
error example 7
  # given: synopsis;
  my $error = $throw->error({
    name => 'on.test.error',
    context => 'Test.error',
    message => 'Something failed!',
  });
  # bless({
  #   ...,
  #   "context"  => "Test.error",
  #   "message"  => "Something failed!",
  #   "name"  => "on_test_error",
  # }, "Main::Error")
    

  on(string $name) (Venus::Throw)

The on method sets a "name" for the error in the form of "on.$subroutine.$name" or "on.$name" (if outside of a subroutine) and returns the invocant.

Since 2.55

on example 1
  # given: synopsis
  package main;
  $throw = $throw->on('handler');
  # bless({...}, 'Venus::Throw')
  # $throw->name;
  # "on.handler"
    
on example 2
  # given: synopsis
  package main;
  sub execute {
    $throw->on('handler');
  }
  $throw = execute();
  # bless({...}, 'Venus::Throw')
  # $throw->name;
  # "on.execute.handler"
    

This package overloads the following operators:

This package overloads the "" operator.

example 1

  # given: synopsis;
  my $result = "$throw";
  # "Exception!"
    
This package overloads the "~~" operator.

example 1

  # given: synopsis;
  my $result = $throw ~~ 'Exception!';
  # 1
    

Awncorp, "awncorp@cpan.org"

Copyright (C) 2022, Awncorp, "awncorp@cpan.org".

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

2023-11-27 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.