| 1 | package Broadworks::OCIP::Throwable; | ||
| 2 | |||
| 3 | # ABSTRACT: Exception throwing for Broadworks::OCIP | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use utf8; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | our $VERSION = '0.08'; # VERSION | ||
| 11 | our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY | ||
| 12 | |||
| 13 | use Moose; | ||
| 14 | extends 'Throwable::Error'; | ||
| 15 | |||
| 16 | |||
| 17 | # ------------------------------------------------------------------------ | ||
| 18 | |||
| 19 | has execution_phase => ( | ||
| 20 | is => 'ro', | ||
| 21 | isa => 'Str', | ||
| 22 | default => 'unknown', | ||
| 23 | ); | ||
| 24 | |||
| 25 | has error_code => ( | ||
| 26 | is => 'ro', | ||
| 27 | isa => 'Str', | ||
| 28 | default => 'error', | ||
| 29 | ); | ||
| 30 | |||
| 31 | # ------------------------------------------------------------------------ | ||
| 32 | |||
| 33 | |||
| 34 | around _build_stack_trace_args => sub { | ||
| 35 | my ( $orig, $self, @rest ) = @_; | ||
| 36 | my $args_array = $self->$orig(@rest); | ||
| 37 | push( @{$args_array}, no_refs => 1 ); | ||
| 38 | return $args_array; | ||
| 39 | }; | ||
| 40 | |||
| 41 | # ------------------------------------------------------------------------ | ||
| 42 | __PACKAGE__->meta->make_immutable; | ||
| 43 | 1; | ||
| 44 | |||
| 45 | __END__ | ||
| 46 | |||
| 47 | =pod | ||
| 48 | |||
| 49 | =encoding UTF-8 | ||
| 50 | |||
| 51 | =head1 NAME | ||
| 52 | |||
| 53 | Broadworks::OCIP::Throwable - Exception throwing for Broadworks::OCIP | ||
| 54 | |||
| 55 | =head1 VERSION | ||
| 56 | |||
| 57 | version 0.08 | ||
| 58 | |||
| 59 | =for test_synopsis 1; | ||
| 60 | __END__ | ||
| 61 | |||
| 62 | =for stopwords NIGELM | ||
| 63 | |||
| 64 | =for Pod::Coverage mvp_multivalue_args | ||
| 65 | |||
| 66 | =head1 SYNOPSIS | ||
| 67 | |||
| 68 | use Broadworks::OCIP::Throwable; | ||
| 69 | |||
| 70 | Broadworks::OCIP::Throwable->throw(...); | ||
| 71 | |||
| 72 | =head1 DESCRIPTION | ||
| 73 | |||
| 74 | Throws an exception. | ||
| 75 | |||
| 76 | =head2 Required Parameters | ||
| 77 | |||
| 78 | =head3 message | ||
| 79 | |||
| 80 | An exception message. | ||
| 81 | |||
| 82 | =head3 execution_phase | ||
| 83 | |||
| 84 | Text to give an indication of what we were doing. | ||
| 85 | |||
| 86 | =head3 error_code | ||
| 87 | |||
| 88 | Text to uniquely identify what caused this. | ||
| 89 | |||
| 90 | =head3 _build_stack_trace_args | ||
| 91 | |||
| 92 | Modifies the stack trace to have no_refs set, otherwise the Devel::StackTrace | ||
| 93 | objects leak, causing a build up of unreclaimable memory. | ||
| 94 | |||
| 95 | Taken from a post by Bill Moseley at | ||
| 96 | L<http://www.nntp.perl.org/group/perl.moose/2013/02/msg2574.html> | ||
| 97 | |||
| 98 | =head1 AUTHOR | ||
| 99 | |||
| 100 | Nigel Metheringham <Nigel.Metheringham@redcentricplc.com> | ||
| 101 | |||
| 102 | =head1 COPYRIGHT | ||
| 103 | |||
| 104 | Copyright 2014 Recentric Solutions Limited. All rights reserved. | ||
| 105 | |||
| 106 | =head1 AUTHOR | ||
| 107 | |||
| 108 | Nigel Metheringham <nigelm@cpan.org> | ||
| 109 | |||
| 110 | =head1 COPYRIGHT AND LICENSE | ||
| 111 | |||
| 112 | This software is copyright (c) 2018 by Nigel Metheringham. | ||
| 113 | |||
| 114 | This is free software; you can redistribute it and/or modify it under | ||
| 115 | the same terms as the Perl 5 programming language system itself. | ||
| 116 | |||
| 117 | =cut |