From c192d08bdb4696e8722addbafdc31b0a71e9c735 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Tue, 19 Jul 2022 15:14:35 +0900 Subject: [PATCH] Imported Upstream version 0.17027 --- Build.PL | 79 ++- ChangeLog | 72 ++- Changes | 7 + LICENSE | 396 ++++++++++++++ MANIFEST | 27 +- MANIFEST.SKIP | 1 + META.json | 551 +++++++++++++++++++- META.yml | 415 ++++++++++++++- Makefile.PL | 81 ++- README | 92 +--- dist.ini | 15 + examples/example.pl | 11 +- examples/next-in-loop/README | 2 +- examples/warndie.pl | 1 + inc/Test/Run/Builder.pm | 2 +- lib/Error.pm | 764 +++++++++++++++++----------- lib/Error/Simple.pm | 157 +++++- scripts/bump-version-number.pl | 43 ++ t/00-compile.t | 61 +++ t/01throw.t | 5 +- t/02order.t | 72 +-- t/05text-errors-with-file-handles.t | 2 +- t/06customize-text-throw.t | 3 +- t/07try-in-obj-destructor.t | 3 +- t/08warndie.t | 17 +- t/10throw-in-catch.t | 4 +- t/11rethrow.t | 49 +- t/14Error-Simple-VERSION.t | 18 + t/lib/MyDie.pm | 3 + t/pod-coverage.t | 6 - t/pod.t | 6 - weaver.ini | 1 + xt/author/eol.t | 31 ++ xt/author/no-tabs.t | 31 ++ xt/author/pod-coverage.t | 7 + xt/author/pod-syntax.t | 7 + xt/release/cpan-changes.t | 10 + xt/release/trailing-space.t | 30 ++ 38 files changed, 2554 insertions(+), 528 deletions(-) create mode 100644 Changes create mode 100644 LICENSE create mode 100644 MANIFEST.SKIP create mode 100644 dist.ini create mode 100644 scripts/bump-version-number.pl create mode 100644 t/00-compile.t create mode 100644 t/14Error-Simple-VERSION.t delete mode 100644 t/pod-coverage.t delete mode 100644 t/pod.t create mode 100644 weaver.ini create mode 100644 xt/author/eol.t create mode 100644 xt/author/no-tabs.t create mode 100644 xt/author/pod-coverage.t create mode 100644 xt/author/pod-syntax.t create mode 100644 xt/release/cpan-changes.t create mode 100644 xt/release/trailing-space.t diff --git a/Build.PL b/Build.PL index ccf7ee4..f85cfee 100644 --- a/Build.PL +++ b/Build.PL @@ -1,21 +1,68 @@ + +# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.012. use strict; use warnings; -use File::Spec; -use lib File::Spec->catdir(File::Spec->curdir(), "inc"); - -use Test::Run::Builder; - -my $build = Test::Run::Builder->new( - 'module_name' => "Error", - 'requires' => - { - 'Scalar::Util' => 0, - 'perl' => "5.6.0", - 'warnings' => 0, - }, - 'license' => "perl", - 'dist_abstract' => 'Error/exception handling in an OO-ish way', - 'dist_author' => 'Shlomi Fish ', +use Module::Build 0.28; + + +my %module_build_args = ( + "build_requires" => { + "Module::Build" => "0.28" + }, + "configure_requires" => { + "ExtUtils::MakeMaker" => 0, + "Module::Build" => "0.28" + }, + "dist_abstract" => "Error/exception handling in an OO-ish way", + "dist_author" => [ + "Shlomi Fish ( http://www.shlomifish.org/ )" + ], + "dist_name" => "Error", + "dist_version" => "0.17027", + "license" => "perl", + "module_name" => "Error", + "recursive_test_files" => 1, + "requires" => { + "Carp" => 0, + "Exporter" => 0, + "Scalar::Util" => 0, + "overload" => 0, + "perl" => "5.006", + "strict" => 0, + "vars" => 0, + "warnings" => 0 + }, + "test_requires" => { + "File::Spec" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Test::More" => "0.88", + "base" => 0, + "lib" => 0, + "perl" => "5.006" + } +); + + +my %fallback_build_requires = ( + "File::Spec" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Module::Build" => "0.28", + "Test::More" => "0.88", + "base" => 0, + "lib" => 0, + "perl" => "5.006" ); + + +unless ( eval { Module::Build->VERSION(0.4004) } ) { + delete $module_build_args{test_requires}; + $module_build_args{build_requires} = \%fallback_build_requires; +} + +my $build = Module::Build->new(%module_build_args); + + $build->create_build_script; diff --git a/ChangeLog b/ChangeLog index 423d766..96dc256 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,68 @@ +May 23 2018 (Shlomi Fish) + + Error.pm #0.17026 + - Convert to Dist-Zilla. + +Aug 07 2017 (Shlomi Fish) + + Error.pm #0.17025 + - Fix 'use Error::Simple' overriding the $VERSION + - https://rt.cpan.org/Public/Bug/Display.html?id=122713 + - Thanks to Matthew Horsfall for the report. + +May 30 2015 (Shlomi Fish) + + Error.pm #0.17024 + - Add link to the VCS repository in META.yml + +Feb 12 2015 (Shlomi Fish) + + Error.pm #0.17023 + - Minimal version of Module-Build reduced to 0.280801 + - https://rt.cpan.org/Public/Bug/Display.html?id=102062 + +Jan 29 2014 (Shlomi Fish) + + Error.pm #0.17022 + - Add "use warnings;" to everything (CPANTS Kwalitee). + - Add a separate LICENSE file (CPANTS Kwalitee). + +Aug 27 2013 (Shlomi Fish) + + Error.pm #0.17021 + - Fix for the format of the new Carp (in bleadperl) + - https://rt.cpan.org/Ticket/Display.html?id=88137 + - Thanks to Zefram for the report and patch. + +May 03 2013 (Shlomi Fish) + + Error.pm #0.17020 + - Correct typos. + - https://rt.cpan.org/Ticket/Display.html?id=85023 + +Nov 19 2012 (Shlomi Fish) + + Error.pm #0.17019 + - Change to Shlomi Fish's new E-mail and web address. + - Clarify the licence of lib/Error/Simple.pm . + - https://rt.cpan.org/Ticket/Display.html?id=81277 + - Thanks to Marcela + +May 08 2012 (Shlomi Fish) + + Error.pm #0.17018 + - Add a $VERSION variable for Error::Simple. + - thanks to Kevin Dawson for the report. + - Add scripts/bump-version-number.pl . + - This can be used to bump the version numbers globally. + Feb 11 2012 (Shlomi Fish) - - Bleadperl broke Error.pm's tests - + - Bleadperl broke Error.pm's tests - - https://rt.cpan.org/Ticket/Display.html?id=74770 - Applied a patch to check for optional trailing periods. - Thanks to ANDK for the report and RURBAN for the patch - + Dec 19 2009 (Shlomi Fish) Error.pm #0.17016 @@ -54,7 +112,7 @@ Nov 22 2007 (Shlomi Fish) Error.pm #0.17010 - moved the first Error->new() POD portion over to the POD at the bottom, and deleted the second, identical POD portion. - - closing http://rt.cpan.org/Public/Bug/Display.html?id=30906 + - closing http://rt.cpan.org/Public/Bug/Display.html?id=30906 ( "Duplicate Error->new() documentation" ) Aug 28 2007 (Shlomi Fish) @@ -98,7 +156,7 @@ Oct 03 2006 (Shlomi Fish) the MANIFEST previously. - t/10throw-in-catch.t, t/Error.pm - Fixed: http://rt.cpan.org/Public/Bug/Display.html?id=21884 when an error that - was thrown inside a catch or otherwise clause was not registered. + was thrown inside a catch or otherwise clause was not registered. Sep 01 2006 (Paul Evans) @@ -156,7 +214,7 @@ Apr 24 2006 (Shlomi Fish) Apr 07 2006 (Shlomi Fish) Error.pm #0.15008 - - Fixed a test in t/05text-errors-with-file-handles.t to work on + - Fixed a test in t/05text-errors-with-file-handles.t to work on MS Windows due to File::Spec and require inconsistency. Apr 07 2006 (Shlomi Fish) @@ -186,7 +244,7 @@ Mar 31 2006 (Shlomi Fish) Error.pm #0.15003 - Added the lib/Error/Simple.pm module (that just "use"'s Error) so - one can say "use base 'Error::Simple';' Added an appropriate test. + one can say "use base 'Error::Simple';' Added an appropriate test. Fixes: http://rt.cpan.org/Public/Bug/Display.html?id=17841 Mar 30 2006 (Shlomi Fish) @@ -213,7 +271,7 @@ May 12 2001 (Arun Kumar U) Error.pm #0.14 - Added overloading method for 'bool'. This was neccessary so that - examining the value of $@ after a eval block, returns a true + examining the value of $@ after a eval block, returns a true value - Applied the diffs from Graham's code base - Changed README with more information about the module diff --git a/Changes b/Changes new file mode 100644 index 0000000..557804e --- /dev/null +++ b/Changes @@ -0,0 +1,7 @@ +0.17027 2018-10-28 + - Documentation and examples enhancements. + - https://bitbucket.org/shlomif/perl-error.pm/pull-requests/1/october-prc-some-minor-mostly-doc-changes/diff + - Thanks to https://metacpan.org/author/JMERELO . + +0.17026 2018-05-23 + - Convert to Dist-Zilla. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0ba8d2b --- /dev/null +++ b/LICENSE @@ -0,0 +1,396 @@ +Terms of Perl itself + +a) the GNU General Public License as published by the Free + Software Foundation; either version 1, or (at your option) any + later version, or +b) the "Artistic License" + +---------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + +---------------------------------------------------------------------------- + +The Artistic License + +Preamble + +The intent of this document is to state the conditions under which a Package +may be copied, such that the Copyright Holder maintains some semblance of +artistic control over the development of the package, while giving the users of the +package the right to use and distribute the Package in a more-or-less customary +fashion, plus the right to make reasonable modifications. + +Definitions: + +- "Package" refers to the collection of files distributed by the Copyright + Holder, and derivatives of that collection of files created through textual + modification. +- "Standard Version" refers to such a Package if it has not been modified, + or has been modified in accordance with the wishes of the Copyright + Holder. +- "Copyright Holder" is whoever is named in the copyright or copyrights for + the package. +- "You" is you, if you're thinking about copying or distributing this Package. +- "Reasonable copying fee" is whatever you can justify on the basis of + media cost, duplication charges, time of people involved, and so on. (You + will not be required to justify it to the Copyright Holder, but only to the + computing community at large as a market that must bear the fee.) +- "Freely Available" means that no fee is charged for the item itself, though + there may be fees involved in handling the item. It also means that + recipients of the item may redistribute it under the same conditions they + received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you duplicate +all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications derived from +the Public Domain or from the Copyright Holder. A Package modified in such a +way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and when +you changed that file, and provided that you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said modifications + to Usenet or an equivalent medium, or placing the modifications on + a major archive site such as ftp.uu.net, or by allowing the + Copyright Holder to include your modifications in the Standard + Version of the Package. + + b) use the modified Package only within your corporation or + organization. + + c) rename any non-standard executables so the names do not + conflict with standard executables, which must also be provided, + and provide a separate manual page for each non-standard + executable that clearly documents how it differs from the Standard + Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or executable +form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library + files, together with instructions (in the manual page or equivalent) + on where to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) accompany any non-standard executables with their + corresponding Standard Version executables, giving the + non-standard executables non-standard names, and clearly + documenting the differences in manual pages (or equivalent), + together with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this Package. +You may charge any fee you choose for support of this Package. You may not +charge a fee for this Package itself. However, you may distribute this Package in +aggregate with other (possibly commercial) programs as part of a larger +(possibly commercial) software distribution provided that you do not advertise +this Package as a product of your own. + +6. The scripts and library files supplied as input to or produced as output from +the programs of this Package do not automatically fall under the copyright of this +Package, but belong to whomever generated them, and may be sold +commercially, and may be aggregated with this Package. + +7. C or perl subroutines supplied by you and linked into this Package shall not +be considered part of this Package. + +8. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR +PURPOSE. + +The End + diff --git a/MANIFEST b/MANIFEST index 731afa5..39a3818 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,5 +1,15 @@ +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. Build.PL ChangeLog +Changes +LICENSE +MANIFEST +MANIFEST.SKIP +META.json +META.yml +Makefile.PL +README +dist.ini examples/example.pl examples/next-in-loop/Error.pm-eval.pl examples/next-in-loop/Error.pm-next-label.pl @@ -10,10 +20,8 @@ examples/warndie.pl inc/Test/Run/Builder.pm lib/Error.pm lib/Error/Simple.pm -Makefile.PL -MANIFEST -META.yml Module meta-data (added by MakeMaker) -README +scripts/bump-version-number.pl +t/00-compile.t t/01throw.t t/02order.t t/03throw-non-Error.t @@ -27,7 +35,12 @@ t/10throw-in-catch.t t/11rethrow.t t/12wrong-error-var.t t/13except-arg0.t +t/14Error-Simple-VERSION.t t/lib/MyDie.pm -t/pod-coverage.t -t/pod.t -META.json +weaver.ini +xt/author/eol.t +xt/author/no-tabs.t +xt/author/pod-coverage.t +xt/author/pod-syntax.t +xt/release/cpan-changes.t +xt/release/trailing-space.t diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..2e58f07 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1 @@ +~$ diff --git a/META.json b/META.json index 5496339..70e8c89 100644 --- a/META.json +++ b/META.json @@ -1,55 +1,574 @@ { "abstract" : "Error/exception handling in an OO-ish way", "author" : [ - "Shlomi Fish " + "Shlomi Fish ( http://www.shlomifish.org/ )" + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010", + "keywords" : [ + "deprecated", + "exceptions", + "oop" ], - "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.113640", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", - "version" : "2" + "version" : 2 }, "name" : "Error", "prereqs" : { + "build" : { + "requires" : { + "Module::Build" : "0.28" + } + }, "configure" : { "requires" : { - "Module::Build" : "0.38" + "ExtUtils::MakeMaker" : "0", + "Module::Build" : "0.28" + } + }, + "develop" : { + "requires" : { + "Pod::Coverage::TrustPod" : "0", + "Test::CPAN::Changes" : "0.19", + "Test::EOL" : "0", + "Test::More" : "0.96", + "Test::NoTabs" : "0", + "Test::Pod" : "1.41", + "Test::Pod::Coverage" : "1.08", + "Test::TrailingSpace" : "0.0203" } }, "runtime" : { "requires" : { - "Scalar::Util" : 0, - "perl" : "v5.6.0", - "warnings" : 0 + "Carp" : "0", + "Exporter" : "0", + "Scalar::Util" : "0", + "overload" : "0", + "perl" : "5.006", + "strict" : "0", + "vars" : "0", + "warnings" : "0" + } + }, + "test" : { + "requires" : { + "File::Spec" : "0", + "IO::Handle" : "0", + "IPC::Open3" : "0", + "Test::More" : "0.88", + "base" : "0", + "lib" : "0", + "perl" : "5.006" } } }, "provides" : { "Error" : { "file" : "lib/Error.pm", - "version" : "0.17017" + "version" : "0.17027" }, "Error::Simple" : { "file" : "lib/Error.pm", - "version" : 0 + "version" : "0.17027" }, "Error::WarnDie" : { "file" : "lib/Error.pm", - "version" : 0 + "version" : "0.17027" }, "Error::subs" : { "file" : "lib/Error.pm", - "version" : 0 + "version" : "0.17027" } }, "release_status" : "stable", "resources" : { - "license" : [ - "http://dev.perl.org/licenses/" - ] + "bugtracker" : { + "web" : "https://github.com/shlomif/error/issues" + }, + "homepage" : "http://metacpan.org/release/Error", + "repository" : { + "type" : "git", + "url" : "https://bitbucket.org/shlomif/perl-error.pm", + "web" : "https://github.com/shlomif/error" + } + }, + "version" : "0.17027", + "x_Dist_Zilla" : { + "perl" : { + "version" : "5.028000" + }, + "plugins" : [ + { + "class" : "Dist::Zilla::Plugin::Prereqs", + "config" : { + "Dist::Zilla::Plugin::Prereqs" : { + "phase" : "test", + "type" : "requires" + } + }, + "name" : "@Filter/TestMoreDoneTesting", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::AutoPrereqs", + "name" : "@Filter/AutoPrereqs", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::ExecDir", + "name" : "@Filter/ExecDir", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::GatherDir", + "config" : { + "Dist::Zilla::Plugin::GatherDir" : { + "exclude_filename" : [], + "exclude_match" : [], + "follow_symlinks" : 0, + "include_dotfiles" : 0, + "prefix" : "", + "prune_directory" : [], + "root" : "." + } + }, + "name" : "@Filter/GatherDir", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::ManifestSkip", + "name" : "@Filter/ManifestSkip", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::MetaYAML", + "name" : "@Filter/MetaYAML", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PruneCruft", + "name" : "@Filter/PruneCruft", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Readme", + "name" : "@Filter/Readme", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::RunExtraTests", + "config" : { + "Dist::Zilla::Role::TestRunner" : { + "default_jobs" : 1 + } + }, + "name" : "@Filter/RunExtraTests", + "version" : "0.029" + }, + { + "class" : "Dist::Zilla::Plugin::ShareDir", + "name" : "@Filter/ShareDir", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::MakeMaker", + "config" : { + "Dist::Zilla::Role::TestRunner" : { + "default_jobs" : 1 + } + }, + "name" : "@Filter/MakeMaker", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::CheckChangesHasContent", + "name" : "@Filter/CheckChangesHasContent", + "version" : "0.011" + }, + { + "class" : "Dist::Zilla::Plugin::ConfirmRelease", + "name" : "@Filter/ConfirmRelease", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Manifest", + "name" : "@Filter/Manifest", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::MetaConfig", + "name" : "@Filter/MetaConfig", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::MetaJSON", + "name" : "@Filter/MetaJSON", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::MetaProvides::Package", + "config" : { + "Dist::Zilla::Plugin::MetaProvides::Package" : { + "finder_objects" : [ + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", + "version" : "6.012" + } + ], + "include_underscores" : 0 + }, + "Dist::Zilla::Role::MetaProvider::Provider" : { + "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", + "inherit_missing" : 1, + "inherit_version" : 1, + "meta_noindex" : 1 + }, + "Dist::Zilla::Role::ModuleMetadata" : { + "Module::Metadata" : "1.000033", + "version" : "0.006" + } + }, + "name" : "@Filter/MetaProvides::Package", + "version" : "2.004003" + }, + { + "class" : "Dist::Zilla::Plugin::MetaResources", + "name" : "@Filter/MetaResources", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::ModuleBuild", + "config" : { + "Dist::Zilla::Role::TestRunner" : { + "default_jobs" : 1 + } + }, + "name" : "@Filter/ModuleBuild", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PkgVersion", + "name" : "@Filter/PkgVersion", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PodCoverageTests", + "name" : "@Filter/PodCoverageTests", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PodSyntaxTests", + "name" : "@Filter/PodSyntaxTests", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PodVersion", + "name" : "@Filter/PodVersion", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Test::Compile", + "config" : { + "Dist::Zilla::Plugin::Test::Compile" : { + "bail_out_on_fail" : 0, + "fail_on_warning" : "author", + "fake_home" : 0, + "filename" : "t/00-compile.t", + "module_finder" : [ + ":InstallModules" + ], + "needs_display" : 0, + "phase" : "test", + "script_finder" : [ + ":PerlExecFiles" + ], + "skips" : [], + "switch" : [] + } + }, + "name" : "@Filter/Test::Compile", + "version" : "2.058" + }, + { + "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", + "config" : { + "Dist::Zilla::Plugin::Test::CPAN::Changes" : { + "changelog" : "Changes" + } + }, + "name" : "@Filter/Test::CPAN::Changes", + "version" : "0.012" + }, + { + "class" : "Dist::Zilla::Plugin::Test::EOL", + "config" : { + "Dist::Zilla::Plugin::Test::EOL" : { + "filename" : "xt/author/eol.t", + "finder" : [ + ":ExecFiles", + ":InstallModules", + ":TestFiles" + ], + "trailing_whitespace" : 1 + } + }, + "name" : "@Filter/Test::EOL", + "version" : "0.19" + }, + { + "class" : "Dist::Zilla::Plugin::Test::NoTabs", + "config" : { + "Dist::Zilla::Plugin::Test::NoTabs" : { + "filename" : "xt/author/no-tabs.t", + "finder" : [ + ":InstallModules", + ":ExecFiles", + ":TestFiles" + ] + } + }, + "name" : "@Filter/Test::NoTabs", + "version" : "0.15" + }, + { + "class" : "Dist::Zilla::Plugin::Test::TrailingSpace", + "name" : "@Filter/Test::TrailingSpace", + "version" : "0.2.0" + }, + { + "class" : "Dist::Zilla::Plugin::TestRelease", + "name" : "@Filter/TestRelease", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::PodWeaver", + "config" : { + "Dist::Zilla::Plugin::PodWeaver" : { + "finder" : [ + ":InstallModules", + ":ExecFiles" + ], + "plugins" : [ + { + "class" : "Pod::Weaver::Plugin::SingleEncoding", + "name" : "@SHLOMIF/SingleEncoding", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Plugin::WikiDoc", + "name" : "@SHLOMIF/WikiDoc", + "version" : "0.093004" + }, + { + "class" : "Pod::Weaver::Plugin::EnsurePod5", + "name" : "@CorePrep/EnsurePod5", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Plugin::H1Nester", + "name" : "@CorePrep/H1Nester", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Name", + "name" : "@SHLOMIF/Name", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Version", + "name" : "@SHLOMIF/Version", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Region", + "name" : "@SHLOMIF/Prelude", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "@SHLOMIF/Synopsis", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "@SHLOMIF/Description", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "@SHLOMIF/Usage", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "@SHLOMIF/Overview", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Generic", + "name" : "@SHLOMIF/Stability", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "Requirements", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "Attributes", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "Constructors", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "Methods", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Collect", + "name" : "Functions", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Leftovers", + "name" : "@SHLOMIF/Leftovers", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Region", + "name" : "@SHLOMIF/postlude", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Support", + "name" : "@SHLOMIF/Support", + "version" : "1.010" + }, + { + "class" : "Pod::Weaver::Section::Authors", + "name" : "@SHLOMIF/Authors", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Bugs", + "name" : "@SHLOMIF/Bugs", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Section::Contributors", + "name" : "@SHLOMIF/Contributors", + "version" : "0.009" + }, + { + "class" : "Pod::Weaver::Section::Legal", + "name" : "@SHLOMIF/Legal", + "version" : "4.015" + }, + { + "class" : "Pod::Weaver::Plugin::Transformer", + "name" : "@SHLOMIF/List", + "version" : "4.015" + } + ] + } + }, + "name" : "@Filter/PodWeaver", + "version" : "4.008" + }, + { + "class" : "Dist::Zilla::Plugin::UploadToCPAN", + "name" : "@Filter/UploadToCPAN", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::Keywords", + "config" : { + "Dist::Zilla::Plugin::Keywords" : { + "keywords" : [ + "deprecated", + "exceptions", + "oop" + ] + } + }, + "name" : "Keywords", + "version" : "0.007" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":InstallModules", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":IncModules", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":TestFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ExtraTestFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ExecFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":PerlExecFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ShareFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":MainModule", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":AllFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":NoFiles", + "version" : "6.012" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : "@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", + "version" : "6.012" + } + ], + "zilla" : { + "class" : "Dist::Zilla::Dist::Builder", + "config" : { + "is_trial" : 0 + }, + "version" : "6.012" + } }, - "version" : "0.17017" + "x_generated_by_perl" : "v5.28.0", + "x_serialization_backend" : "Cpanel::JSON::XS version 4.06" } + diff --git a/META.yml b/META.yml index 68dcdcd..5da4e9d 100644 --- a/META.yml +++ b/META.yml @@ -1,34 +1,419 @@ --- abstract: 'Error/exception handling in an OO-ish way' author: - - 'Shlomi Fish ' -build_requires: {} + - 'Shlomi Fish ( http://www.shlomifish.org/ )' +build_requires: + File::Spec: '0' + IO::Handle: '0' + IPC::Open3: '0' + Module::Build: '0.28' + Test::More: '0.88' + base: '0' + lib: '0' + perl: '5.006' configure_requires: - Module::Build: 0.38 -dynamic_config: 1 -generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.113640' + ExtUtils::MakeMaker: '0' + Module::Build: '0.28' +dynamic_config: 0 +generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010' +keywords: + - deprecated + - exceptions + - oop license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + version: '1.4' name: Error provides: Error: file: lib/Error.pm - version: 0.17017 + version: '0.17027' Error::Simple: file: lib/Error.pm - version: 0 + version: '0.17027' Error::WarnDie: file: lib/Error.pm - version: 0 + version: '0.17027' Error::subs: file: lib/Error.pm - version: 0 + version: '0.17027' requires: - Scalar::Util: 0 - perl: v5.6.0 - warnings: 0 + Carp: '0' + Exporter: '0' + Scalar::Util: '0' + overload: '0' + perl: '5.006' + strict: '0' + vars: '0' + warnings: '0' resources: - license: http://dev.perl.org/licenses/ -version: 0.17017 + bugtracker: https://github.com/shlomif/error/issues + homepage: http://metacpan.org/release/Error + repository: https://bitbucket.org/shlomif/perl-error.pm +version: '0.17027' +x_Dist_Zilla: + perl: + version: '5.028000' + plugins: + - + class: Dist::Zilla::Plugin::Prereqs + config: + Dist::Zilla::Plugin::Prereqs: + phase: test + type: requires + name: '@Filter/TestMoreDoneTesting' + version: '6.012' + - + class: Dist::Zilla::Plugin::AutoPrereqs + name: '@Filter/AutoPrereqs' + version: '6.012' + - + class: Dist::Zilla::Plugin::ExecDir + name: '@Filter/ExecDir' + version: '6.012' + - + class: Dist::Zilla::Plugin::GatherDir + config: + Dist::Zilla::Plugin::GatherDir: + exclude_filename: [] + exclude_match: [] + follow_symlinks: 0 + include_dotfiles: 0 + prefix: '' + prune_directory: [] + root: . + name: '@Filter/GatherDir' + version: '6.012' + - + class: Dist::Zilla::Plugin::ManifestSkip + name: '@Filter/ManifestSkip' + version: '6.012' + - + class: Dist::Zilla::Plugin::MetaYAML + name: '@Filter/MetaYAML' + version: '6.012' + - + class: Dist::Zilla::Plugin::PruneCruft + name: '@Filter/PruneCruft' + version: '6.012' + - + class: Dist::Zilla::Plugin::Readme + name: '@Filter/Readme' + version: '6.012' + - + class: Dist::Zilla::Plugin::RunExtraTests + config: + Dist::Zilla::Role::TestRunner: + default_jobs: 1 + name: '@Filter/RunExtraTests' + version: '0.029' + - + class: Dist::Zilla::Plugin::ShareDir + name: '@Filter/ShareDir' + version: '6.012' + - + class: Dist::Zilla::Plugin::MakeMaker + config: + Dist::Zilla::Role::TestRunner: + default_jobs: 1 + name: '@Filter/MakeMaker' + version: '6.012' + - + class: Dist::Zilla::Plugin::CheckChangesHasContent + name: '@Filter/CheckChangesHasContent' + version: '0.011' + - + class: Dist::Zilla::Plugin::ConfirmRelease + name: '@Filter/ConfirmRelease' + version: '6.012' + - + class: Dist::Zilla::Plugin::Manifest + name: '@Filter/Manifest' + version: '6.012' + - + class: Dist::Zilla::Plugin::MetaConfig + name: '@Filter/MetaConfig' + version: '6.012' + - + class: Dist::Zilla::Plugin::MetaJSON + name: '@Filter/MetaJSON' + version: '6.012' + - + class: Dist::Zilla::Plugin::MetaProvides::Package + config: + Dist::Zilla::Plugin::MetaProvides::Package: + finder_objects: + - + class: Dist::Zilla::Plugin::FinderCode + name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' + version: '6.012' + include_underscores: 0 + Dist::Zilla::Role::MetaProvider::Provider: + $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' + inherit_missing: '1' + inherit_version: '1' + meta_noindex: '1' + Dist::Zilla::Role::ModuleMetadata: + Module::Metadata: '1.000033' + version: '0.006' + name: '@Filter/MetaProvides::Package' + version: '2.004003' + - + class: Dist::Zilla::Plugin::MetaResources + name: '@Filter/MetaResources' + version: '6.012' + - + class: Dist::Zilla::Plugin::ModuleBuild + config: + Dist::Zilla::Role::TestRunner: + default_jobs: 1 + name: '@Filter/ModuleBuild' + version: '6.012' + - + class: Dist::Zilla::Plugin::PkgVersion + name: '@Filter/PkgVersion' + version: '6.012' + - + class: Dist::Zilla::Plugin::PodCoverageTests + name: '@Filter/PodCoverageTests' + version: '6.012' + - + class: Dist::Zilla::Plugin::PodSyntaxTests + name: '@Filter/PodSyntaxTests' + version: '6.012' + - + class: Dist::Zilla::Plugin::PodVersion + name: '@Filter/PodVersion' + version: '6.012' + - + class: Dist::Zilla::Plugin::Test::Compile + config: + Dist::Zilla::Plugin::Test::Compile: + bail_out_on_fail: '0' + fail_on_warning: author + fake_home: 0 + filename: t/00-compile.t + module_finder: + - ':InstallModules' + needs_display: 0 + phase: test + script_finder: + - ':PerlExecFiles' + skips: [] + switch: [] + name: '@Filter/Test::Compile' + version: '2.058' + - + class: Dist::Zilla::Plugin::Test::CPAN::Changes + config: + Dist::Zilla::Plugin::Test::CPAN::Changes: + changelog: Changes + name: '@Filter/Test::CPAN::Changes' + version: '0.012' + - + class: Dist::Zilla::Plugin::Test::EOL + config: + Dist::Zilla::Plugin::Test::EOL: + filename: xt/author/eol.t + finder: + - ':ExecFiles' + - ':InstallModules' + - ':TestFiles' + trailing_whitespace: 1 + name: '@Filter/Test::EOL' + version: '0.19' + - + class: Dist::Zilla::Plugin::Test::NoTabs + config: + Dist::Zilla::Plugin::Test::NoTabs: + filename: xt/author/no-tabs.t + finder: + - ':InstallModules' + - ':ExecFiles' + - ':TestFiles' + name: '@Filter/Test::NoTabs' + version: '0.15' + - + class: Dist::Zilla::Plugin::Test::TrailingSpace + name: '@Filter/Test::TrailingSpace' + version: 0.2.0 + - + class: Dist::Zilla::Plugin::TestRelease + name: '@Filter/TestRelease' + version: '6.012' + - + class: Dist::Zilla::Plugin::PodWeaver + config: + Dist::Zilla::Plugin::PodWeaver: + finder: + - ':InstallModules' + - ':ExecFiles' + plugins: + - + class: Pod::Weaver::Plugin::SingleEncoding + name: '@SHLOMIF/SingleEncoding' + version: '4.015' + - + class: Pod::Weaver::Plugin::WikiDoc + name: '@SHLOMIF/WikiDoc' + version: '0.093004' + - + class: Pod::Weaver::Plugin::EnsurePod5 + name: '@CorePrep/EnsurePod5' + version: '4.015' + - + class: Pod::Weaver::Plugin::H1Nester + name: '@CorePrep/H1Nester' + version: '4.015' + - + class: Pod::Weaver::Section::Name + name: '@SHLOMIF/Name' + version: '4.015' + - + class: Pod::Weaver::Section::Version + name: '@SHLOMIF/Version' + version: '4.015' + - + class: Pod::Weaver::Section::Region + name: '@SHLOMIF/Prelude' + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: '@SHLOMIF/Synopsis' + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: '@SHLOMIF/Description' + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: '@SHLOMIF/Usage' + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: '@SHLOMIF/Overview' + version: '4.015' + - + class: Pod::Weaver::Section::Generic + name: '@SHLOMIF/Stability' + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: Requirements + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: Attributes + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: Constructors + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: Methods + version: '4.015' + - + class: Pod::Weaver::Section::Collect + name: Functions + version: '4.015' + - + class: Pod::Weaver::Section::Leftovers + name: '@SHLOMIF/Leftovers' + version: '4.015' + - + class: Pod::Weaver::Section::Region + name: '@SHLOMIF/postlude' + version: '4.015' + - + class: Pod::Weaver::Section::Support + name: '@SHLOMIF/Support' + version: '1.010' + - + class: Pod::Weaver::Section::Authors + name: '@SHLOMIF/Authors' + version: '4.015' + - + class: Pod::Weaver::Section::Bugs + name: '@SHLOMIF/Bugs' + version: '4.015' + - + class: Pod::Weaver::Section::Contributors + name: '@SHLOMIF/Contributors' + version: '0.009' + - + class: Pod::Weaver::Section::Legal + name: '@SHLOMIF/Legal' + version: '4.015' + - + class: Pod::Weaver::Plugin::Transformer + name: '@SHLOMIF/List' + version: '4.015' + name: '@Filter/PodWeaver' + version: '4.008' + - + class: Dist::Zilla::Plugin::UploadToCPAN + name: '@Filter/UploadToCPAN' + version: '6.012' + - + class: Dist::Zilla::Plugin::Keywords + config: + Dist::Zilla::Plugin::Keywords: + keywords: + - deprecated + - exceptions + - oop + name: Keywords + version: '0.007' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':InstallModules' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':IncModules' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':TestFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':ExtraTestFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':ExecFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':PerlExecFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':ShareFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':MainModule' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':AllFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: ':NoFiles' + version: '6.012' + - + class: Dist::Zilla::Plugin::FinderCode + name: '@Filter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' + version: '6.012' + zilla: + class: Dist::Zilla::Dist::Builder + config: + is_trial: '0' + version: '6.012' +x_generated_by_perl: v5.28.0 +x_serialization_backend: 'YAML::Tiny version 1.73' diff --git a/Makefile.PL b/Makefile.PL index 672131b..0427bf2 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,15 +1,74 @@ +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. +use strict; +use warnings; + use 5.006; + use ExtUtils::MakeMaker; -WriteMakefile( - NAME => 'Error', - VERSION_FROM => 'lib/Error.pm', - PREREQ_PM => - { - 'Scalar::Util' => 0, - 'warnings' => 0, - }, - AUTHOR => 'Shlomi Fish ', - ABSTRACT => 'Error/exception handling in an OO-ish way', - PL_FILES => {}, +my %WriteMakefileArgs = ( + "ABSTRACT" => "Error/exception handling in an OO-ish way", + "AUTHOR" => "Shlomi Fish ( http://www.shlomifish.org/ )", + "BUILD_REQUIRES" => { + "Module::Build" => "0.28" + }, + "CONFIGURE_REQUIRES" => { + "ExtUtils::MakeMaker" => 0, + "Module::Build" => "0.28" + }, + "DISTNAME" => "Error", + "LICENSE" => "perl", + "MIN_PERL_VERSION" => "5.006", + "NAME" => "Error", + "PREREQ_PM" => { + "Carp" => 0, + "Exporter" => 0, + "Scalar::Util" => 0, + "overload" => 0, + "strict" => 0, + "vars" => 0, + "warnings" => 0 + }, + "TEST_REQUIRES" => { + "File::Spec" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Test::More" => "0.88", + "base" => 0, + "lib" => 0 + }, + "VERSION" => "0.17027", + "test" => { + "TESTS" => "t/*.t" + } +); + + +my %FallbackPrereqs = ( + "Carp" => 0, + "Exporter" => 0, + "File::Spec" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Module::Build" => "0.28", + "Scalar::Util" => 0, + "Test::More" => "0.88", + "base" => 0, + "lib" => 0, + "overload" => 0, + "strict" => 0, + "vars" => 0, + "warnings" => 0 ); + + +unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { + delete $WriteMakefileArgs{TEST_REQUIRES}; + delete $WriteMakefileArgs{BUILD_REQUIRES}; + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; +} + +delete $WriteMakefileArgs{CONFIGURE_REQUIRES} + unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; + +WriteMakefile(%WriteMakefileArgs); diff --git a/README b/README index 4405ccb..febac49 100644 --- a/README +++ b/README @@ -1,90 +1,12 @@ -NAME - Error - Error/exception handling in an OO-ish way +This archive contains the distribution Error, +version 0.17027: -DESCRIPTION - The Error package provides two interfaces. Firstly Error provides - a procedural interface to exception handling. Secondly Error is a - base class for errors/exceptions that can either be thrown, for - subsequent catch, or can simply be recorded. + Error/exception handling in an OO-ish way - Errors in the class Error should not be thrown directly, but the - user should throw errors from a sub-class of Error +This software is copyright (c) 2018 by Shlomi Fish ( http://www.shlomifish.org/ ). -SYNOPSIS +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. - use Error qw(:try); - - throw Error::Simple( "A simple error"); - - sub xyz { - ... - record Error::Simple("A simple error") - and return; - } - - unlink($file) or throw Error::Simple("$file: $!",$!); - - try { - do_some_stuff(); - die "error!" if $condition; - throw Error::Simple -text => "Oops!" if $other_condition; - } - catch Error::IO with { - my $E = shift; - print STDERR "File ", $E->{'-file'}, " had a problem\n"; - } - except { - my $E = shift; - my $general_handler=sub {send_message $E->{-description}}; - return { - UserException1 => $general_handler, - UserException2 => $general_handler - }; - } - otherwise { - print STDERR "Well I don't know what to say\n"; - } - finally { - close_the_garage_door_already(); # Should be reliable - }; # Don't forget the trailing ; or you might be surprised - -AUTHORS - - Graham Barr - - The code that inspired me to write this was originally written by - Peter Seibel and adapted by Jesse Glick - . - -MAINTAINER - - Arun Kumar U - - ===================== - -HOW TO INSTALL IT ? - -To install this module, cd to the directory that contains this README -file and type the following: - - perl Makefile.PL - make test - make install - -To install this module into a specific directory, do: -perl Makefile.PL PREFIX=/name/of/the/directory -...the rest is the same... - -Please also read the perlmodinstall man page, if available. - -Share and Enjoy !! - -Arun Kumar U - - -------------------------------------------------------------------------------- - Only wimps use tape backup: *real* men just upload their important - stuff on ftp, and let the rest of the world mirror it. - - Linus Torvalds -------------------------------------------------------------------------------- +This README file was generated by Dist::Zilla::Plugin::Readme v6.012. diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..2a3f5f0 --- /dev/null +++ b/dist.ini @@ -0,0 +1,15 @@ +name = Error +version = 0.17027 +author = Shlomi Fish ( http://www.shlomifish.org/ ) +license = Perl_5 +copyright_holder = Shlomi Fish ( http://www.shlomifish.org/ ) + +[@Filter] +-bundle = @SHLOMIF +-remove = License +dist = Error +repository_url = https://bitbucket.org/shlomif/perl-error.pm +[Keywords] +keyword = deprecated +keyword = exceptions +keyword = oop diff --git a/examples/example.pl b/examples/example.pl index 59da597..929aea6 100644 --- a/examples/example.pl +++ b/examples/example.pl @@ -2,6 +2,9 @@ use lib '.'; use Error qw(:try); +use strict; +use warnings; + @Error::Bad::ISA = qw(Error); $Error::Debug = 1; # turn on verbose stacktrace @@ -17,7 +20,7 @@ sub abc { } except { return { - Error::Simple => sub { warn "simple" } + 'Error::Simple' => sub { warn "simple" } } } otherwise { @@ -40,12 +43,12 @@ sub def { abc(); -$x = prior Error; +my $x = prior Error; print "--\n",$x->stacktrace; unless(defined def()) { - $x = prior Error 'main'; - print "--\n",0+$x,"\n",$x; + my $x = prior Error 'main'; + print "--\n",0+$x,"\n",$x; # 0+$x converts to Integer via "value" method } diff --git a/examples/next-in-loop/README b/examples/next-in-loop/README index f13c21f..a0edcac 100644 --- a/examples/next-in-loop/README +++ b/examples/next-in-loop/README @@ -1,3 +1,3 @@ This is a case study for various ways to implement a "next" command -inside one of the Error.pm clauses, which itself will be inside an +inside one of the Error.pm clauses, which itself will be inside an inner loop inside Error.pm. diff --git a/examples/warndie.pl b/examples/warndie.pl index 23e2e9e..8e96972 100644 --- a/examples/warndie.pl +++ b/examples/warndie.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl -w +# Usage: perl warndie.pl [1 or true or whatever if you want to use warndie] require Error; if( $ARGV[0] ) { import Error qw( :warndie ); diff --git a/inc/Test/Run/Builder.pm b/inc/Test/Run/Builder.pm index 2365c61..7360aa5 100644 --- a/inc/Test/Run/Builder.pm +++ b/inc/Test/Run/Builder.pm @@ -54,7 +54,7 @@ sub do_test_run_tests Test::Run::CmdLine::Iface->new( { 'test_files' => [glob("t/*.t")], - } + } # 'backend_params' => $self->_get_backend_params(), ); diff --git a/lib/Error.pm b/lib/Error.pm index 22d3d9b..4993bcc 100644 --- a/lib/Error.pm +++ b/lib/Error.pm @@ -10,54 +10,55 @@ # but modified ***significantly*** package Error; - +$Error::VERSION = '0.17027'; use strict; -use vars qw($VERSION); -use 5.004; +use warnings; -$VERSION = "0.17017"; +use 5.004; use overload ( - '""' => 'stringify', - '0+' => 'value', - 'bool' => sub { return 1; }, - 'fallback' => 1 + '""' => 'stringify', + '0+' => 'value', + 'bool' => sub { return 1; }, + 'fallback' => 1 ); -$Error::Depth = 0; # Depth to pass to caller() -$Error::Debug = 0; # Generate verbose stack traces -@Error::STACK = (); # Clause stack for try -$Error::THROWN = undef; # last error thrown, a workaround until die $ref works +$Error::Depth = 0; # Depth to pass to caller() +$Error::Debug = 0; # Generate verbose stack traces +@Error::STACK = (); # Clause stack for try +$Error::THROWN = undef; # last error thrown, a workaround until die $ref works -my $LAST; # Last error created -my %ERROR; # Last error associated with package +my $LAST; # Last error created +my %ERROR; # Last error associated with package sub _throw_Error_Simple { my $args = shift; - return Error::Simple->new($args->{'text'}); + return Error::Simple->new( $args->{'text'} ); } $Error::ObjectifyCallback = \&_throw_Error_Simple; - # Exported subs are defined in Error::subs use Scalar::Util (); -sub import { +sub import +{ shift; my @tags = @_; local $Exporter::ExportLevel = $Exporter::ExportLevel + 1; - - @tags = grep { - if( $_ eq ':warndie' ) { - Error::WarnDie->import(); - 0; - } - else { - 1; - } + + @tags = grep { + if ( $_ eq ':warndie' ) + { + Error::WarnDie->import(); + 0; + } + else + { + 1; + } } @tags; Error::subs->import(@tags); @@ -66,73 +67,81 @@ sub import { # I really want to use last for the name of this method, but it is a keyword # which prevent the syntax last Error -sub prior { - shift; # ignore +sub prior +{ + shift; # ignore return $LAST unless @_; my $pkg = shift; return exists $ERROR{$pkg} ? $ERROR{$pkg} : undef - unless ref($pkg); + unless ref($pkg); my $obj = $pkg; my $err = undef; - if($obj->isa('HASH')) { - $err = $obj->{'__Error__'} - if exists $obj->{'__Error__'}; + if ( $obj->isa('HASH') ) + { + $err = $obj->{'__Error__'} + if exists $obj->{'__Error__'}; } - elsif($obj->isa('GLOB')) { - $err = ${*$obj}{'__Error__'} - if exists ${*$obj}{'__Error__'}; + elsif ( $obj->isa('GLOB') ) + { + $err = ${*$obj}{'__Error__'} + if exists ${*$obj}{'__Error__'}; } $err; } -sub flush { - shift; #ignore - - unless (@_) { - $LAST = undef; - return; +sub flush +{ + shift; #ignore + + unless (@_) + { + $LAST = undef; + return; } - + my $pkg = shift; return unless ref($pkg); - - undef $ERROR{$pkg} if defined $ERROR{$pkg}; -} + + undef $ERROR{$pkg} if defined $ERROR{$pkg}; +} # Return as much information as possible about where the error # happened. The -stacktrace element only exists if $Error::DEBUG # was set when the error was created -sub stacktrace { +sub stacktrace +{ my $self = shift; return $self->{'-stacktrace'} - if exists $self->{'-stacktrace'}; + if exists $self->{'-stacktrace'}; my $text = exists $self->{'-text'} ? $self->{'-text'} : "Died"; - $text .= sprintf(" at %s line %d.\n", $self->file, $self->line) - unless($text =~ /\n$/s); + $text .= sprintf( " at %s line %d.\n", $self->file, $self->line ) + unless ( $text =~ /\n$/s ); $text; } - -sub associate { +sub associate +{ my $err = shift; my $obj = shift; return unless ref($obj); - if($obj->isa('HASH')) { - $obj->{'__Error__'} = $err; + if ( $obj->isa('HASH') ) + { + $obj->{'__Error__'} = $err; } - elsif($obj->isa('GLOB')) { - ${*$obj}{'__Error__'} = $err; + elsif ( $obj->isa('GLOB') ) + { + ${*$obj}{'__Error__'} = $err; } $obj = ref($obj); $ERROR{ ref($obj) } = $err; @@ -140,33 +149,37 @@ sub associate { return; } - -sub new { +sub new +{ my $self = shift; - my($pkg,$file,$line) = caller($Error::Depth); + my ( $pkg, $file, $line ) = caller($Error::Depth); my $err = bless { - '-package' => $pkg, - '-file' => $file, - '-line' => $line, - @_ + '-package' => $pkg, + '-file' => $file, + '-line' => $line, + @_ }, $self; - $err->associate($err->{'-object'}) - if(exists $err->{'-object'}); + $err->associate( $err->{'-object'} ) + if ( exists $err->{'-object'} ); # To always create a stacktrace would be very inefficient, so # we only do it if $Error::Debug is set - if($Error::Debug) { - require Carp; - local $Carp::CarpLevel = $Error::Depth; - my $text = defined($err->{'-text'}) ? $err->{'-text'} : "Error"; - my $trace = Carp::longmess($text); - # Remove try calls from the trace - $trace =~ s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; - $trace =~ s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::run_clauses[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; - $err->{'-stacktrace'} = $trace + if ($Error::Debug) + { + require Carp; + local $Carp::CarpLevel = $Error::Depth; + my $text = defined( $err->{'-text'} ) ? $err->{'-text'} : "Error"; + my $trace = Carp::longmess($text); + + # Remove try calls from the trace + $trace =~ +s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; + $trace =~ +s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::run_clauses[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; + $err->{'-stacktrace'} = $trace; } $@ = $LAST = $ERROR{$pkg} = $err; @@ -174,13 +187,14 @@ sub new { # Throw an error. this contains some very gory code. -sub throw { +sub throw +{ my $self = shift; local $Error::Depth = $Error::Depth + 1; # if we are not rethrow-ing then create the object to throw $self = $self->new(@_) unless ref($self); - + die $Error::THROWN = $self; } @@ -188,7 +202,8 @@ sub throw { # # die with Error( ... ); -sub with { +sub with +{ my $self = shift; local $Error::Depth = $Error::Depth + 1; @@ -199,7 +214,8 @@ sub with { # # record Error( ... ) and return; -sub record { +sub record +{ my $self = shift; local $Error::Depth = $Error::Depth + 1; @@ -210,76 +226,86 @@ sub record { # # try { ... } catch CLASS with { ... } -sub catch { - my $pkg = shift; - my $code = shift; +sub catch +{ + my $pkg = shift; + my $code = shift; my $clauses = shift || {}; - my $catch = $clauses->{'catch'} ||= []; + my $catch = $clauses->{'catch'} ||= []; - unshift @$catch, $pkg, $code; + unshift @$catch, $pkg, $code; $clauses; } # Object query methods -sub object { +sub object +{ my $self = shift; exists $self->{'-object'} ? $self->{'-object'} : undef; } -sub file { +sub file +{ my $self = shift; exists $self->{'-file'} ? $self->{'-file'} : undef; } -sub line { +sub line +{ my $self = shift; exists $self->{'-line'} ? $self->{'-line'} : undef; } -sub text { +sub text +{ my $self = shift; exists $self->{'-text'} ? $self->{'-text'} : undef; } # overload methods -sub stringify { +sub stringify +{ my $self = shift; defined $self->{'-text'} ? $self->{'-text'} : "Died"; } -sub value { +sub value +{ my $self = shift; exists $self->{'-value'} ? $self->{'-value'} : undef; } package Error::Simple; - +$Error::Simple::VERSION = '0.17027'; @Error::Simple::ISA = qw(Error); -sub new { - my $self = shift; - my $text = "" . shift; - my $value = shift; - my(@args) = (); +sub new +{ + my $self = shift; + my $text = "" . shift; + my $value = shift; + my (@args) = (); local $Error::Depth = $Error::Depth + 1; - @args = ( -file => $1, -line => $2) - if($text =~ s/\s+at\s+(\S+)\s+line\s+(\d+)(?:,\s*<[^>]*>\s+line\s+\d+)?\.?\n?$//s); - push(@args, '-value', 0 + $value) - if defined($value); + @args = ( -file => $1, -line => $2 ) + if ( $text =~ + s/\s+at\s+(\S+)\s+line\s+(\d+)(?:,\s*<[^>]*>\s+line\s+\d+)?\.?\n?$//s ); + push( @args, '-value', 0 + $value ) + if defined($value); - $self->SUPER::new(-text => $text, @args); + $self->SUPER::new( -text => $text, @args ); } -sub stringify { +sub stringify +{ my $self = shift; my $text = $self->SUPER::stringify; - $text .= sprintf(" at %s line %d.\n", $self->file, $self->line) - unless($text =~ /\n$/s); + $text .= sprintf( " at %s line %d.\n", $self->file, $self->line ) + unless ( $text =~ /\n$/s ); $text; } @@ -290,148 +316,172 @@ sub stringify { # Peter Seibel package Error::subs; - +$Error::subs::VERSION = '0.17027'; use Exporter (); use vars qw(@EXPORT_OK @ISA %EXPORT_TAGS); -@EXPORT_OK = qw(try with finally except otherwise); -%EXPORT_TAGS = (try => \@EXPORT_OK); +@EXPORT_OK = qw(try with finally except otherwise); +%EXPORT_TAGS = ( try => \@EXPORT_OK ); @ISA = qw(Exporter); -sub run_clauses ($$$\@) { - my($clauses,$err,$wantarray,$result) = @_; +sub run_clauses ($$$\@) +{ + my ( $clauses, $err, $wantarray, $result ) = @_; my $code = undef; - $err = $Error::ObjectifyCallback->({'text' =>$err}) unless ref($err); - - CATCH: { - - # catch - my $catch; - if(defined($catch = $clauses->{'catch'})) { - my $i = 0; - - CATCHLOOP: - for( ; $i < @$catch ; $i += 2) { - my $pkg = $catch->[$i]; - unless(defined $pkg) { - #except - splice(@$catch,$i,2,$catch->[$i+1]->($err)); - $i -= 2; - next CATCHLOOP; - } - elsif(Scalar::Util::blessed($err) && $err->isa($pkg)) { - $code = $catch->[$i+1]; - while(1) { - my $more = 0; - local($Error::THROWN, $@); - my $ok = eval { - $@ = $err; - if($wantarray) { - @{$result} = $code->($err,\$more); - } - elsif(defined($wantarray)) { - @{$result} = (); - $result->[0] = $code->($err,\$more); - } - else { - $code->($err,\$more); - } - 1; - }; - if( $ok ) { - next CATCHLOOP if $more; - undef $err; - } - else { - $err = $@ || $Error::THROWN; - $err = $Error::ObjectifyCallback->({'text' =>$err}) - unless ref($err); - } - last CATCH; - }; - } - } - } - - # otherwise - my $owise; - if(defined($owise = $clauses->{'otherwise'})) { - my $code = $clauses->{'otherwise'}; - my $more = 0; - local($Error::THROWN, $@); - my $ok = eval { - $@ = $err; - if($wantarray) { - @{$result} = $code->($err,\$more); - } - elsif(defined($wantarray)) { - @{$result} = (); - $result->[0] = $code->($err,\$more); - } - else { - $code->($err,\$more); - } - 1; - }; - if( $ok ) { - undef $err; - } - else { - $err = $@ || $Error::THROWN; - - $err = $Error::ObjectifyCallback->({'text' =>$err}) - unless ref($err); - } - } + $err = $Error::ObjectifyCallback->( { 'text' => $err } ) unless ref($err); + +CATCH: + { + + # catch + my $catch; + if ( defined( $catch = $clauses->{'catch'} ) ) + { + my $i = 0; + + CATCHLOOP: + for ( ; $i < @$catch ; $i += 2 ) + { + my $pkg = $catch->[$i]; + unless ( defined $pkg ) + { + #except + splice( @$catch, $i, 2, $catch->[ $i + 1 ]->($err) ); + $i -= 2; + next CATCHLOOP; + } + elsif ( Scalar::Util::blessed($err) && $err->isa($pkg) ) + { + $code = $catch->[ $i + 1 ]; + while (1) + { + my $more = 0; + local ( $Error::THROWN, $@ ); + my $ok = eval { + $@ = $err; + if ($wantarray) + { + @{$result} = $code->( $err, \$more ); + } + elsif ( defined($wantarray) ) + { + @{$result} = (); + $result->[0] = $code->( $err, \$more ); + } + else + { + $code->( $err, \$more ); + } + 1; + }; + if ($ok) + { + next CATCHLOOP if $more; + undef $err; + } + else + { + $err = $@ || $Error::THROWN; + $err = $Error::ObjectifyCallback->( + { 'text' => $err } ) + unless ref($err); + } + last CATCH; + } + } + } + } + + # otherwise + my $owise; + if ( defined( $owise = $clauses->{'otherwise'} ) ) + { + my $code = $clauses->{'otherwise'}; + my $more = 0; + local ( $Error::THROWN, $@ ); + my $ok = eval { + $@ = $err; + if ($wantarray) + { + @{$result} = $code->( $err, \$more ); + } + elsif ( defined($wantarray) ) + { + @{$result} = (); + $result->[0] = $code->( $err, \$more ); + } + else + { + $code->( $err, \$more ); + } + 1; + }; + if ($ok) + { + undef $err; + } + else + { + $err = $@ || $Error::THROWN; + + $err = $Error::ObjectifyCallback->( { 'text' => $err } ) + unless ref($err); + } + } } $err; } -sub try (&;$) { - my $try = shift; +sub try (&;$) +{ + my $try = shift; my $clauses = @_ ? shift : {}; - my $ok = 0; - my $err = undef; - my @result = (); + my $ok = 0; + my $err = undef; + my @result = (); unshift @Error::STACK, $clauses; my $wantarray = wantarray(); - do { - local $Error::THROWN = undef; - local $@ = undef; - - $ok = eval { - if($wantarray) { - @result = $try->(); - } - elsif(defined $wantarray) { - $result[0] = $try->(); - } - else { - $try->(); - } - 1; - }; - - $err = $@ || $Error::THROWN - unless $ok; + do + { + local $Error::THROWN = undef; + local $@ = undef; + + $ok = eval { + if ($wantarray) + { + @result = $try->(); + } + elsif ( defined $wantarray ) + { + $result[0] = $try->(); + } + else + { + $try->(); + } + 1; + }; + + $err = $@ || $Error::THROWN + unless $ok; }; shift @Error::STACK; - $err = run_clauses($clauses,$err,wantarray,@result) - unless($ok); + $err = run_clauses( $clauses, $err, wantarray, @result ) + unless ($ok); $clauses->{'finally'}->() - if(defined($clauses->{'finally'})); + if ( defined( $clauses->{'finally'} ) ); - if (defined($err)) + if ( defined($err) ) { - if (Scalar::Util::blessed($err) && $err->can('throw')) + if ( Scalar::Util::blessed($err) && $err->can('throw') ) { throw $err; } @@ -458,11 +508,13 @@ sub try (&;$) { # The catch clause is defined in Error.pm, as the syntax causes it to # be called as a method -sub with (&;$) { - @_ +sub with (&;$) +{ + @_; } -sub finally (&) { +sub finally (&) +{ my $code = shift; my $clauses = { 'finally' => $code }; $clauses; @@ -471,23 +523,26 @@ sub finally (&) { # The except clause is a block which returns a hashref or a list of # key-value pairs, where the keys are the classes and the values are subs. -sub except (&;$) { - my $code = shift; +sub except (&;$) +{ + my $code = shift; my $clauses = shift || {}; - my $catch = $clauses->{'catch'} ||= []; - + my $catch = $clauses->{'catch'} ||= []; + my $sub = sub { - my $ref; - my(@array) = $code->($_[0]); - if(@array == 1 && ref($array[0])) { - $ref = $array[0]; - $ref = [ %$ref ] - if(UNIVERSAL::isa($ref,'HASH')); - } - else { - $ref = \@array; - } - @$ref + my $ref; + my (@array) = $code->( $_[0] ); + if ( @array == 1 && ref( $array[0] ) ) + { + $ref = $array[0]; + $ref = [%$ref] + if ( UNIVERSAL::isa( $ref, 'HASH' ) ); + } + else + { + $ref = \@array; + } + @$ref; }; unshift @{$catch}, undef, $sub; @@ -495,13 +550,15 @@ sub except (&;$) { $clauses; } -sub otherwise (&;$) { +sub otherwise (&;$) +{ my $code = shift; my $clauses = shift || {}; - if(exists $clauses->{'otherwise'}) { - require Carp; - Carp::croak("Multiple otherwise clauses"); + if ( exists $clauses->{'otherwise'} ) + { + require Carp; + Carp::croak("Multiple otherwise clauses"); } $clauses->{'otherwise'} = $code; @@ -512,17 +569,20 @@ sub otherwise (&;$) { 1; package Error::WarnDie; - +$Error::WarnDie::VERSION = '0.17027'; sub gen_callstack($) { - my ( $start ) = @_; + my ($start) = @_; require Carp; local $Carp::CarpLevel = $start; my $trace = Carp::longmess(""); + # Remove try calls from the trace - $trace =~ s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; - $trace =~ s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::run_clauses[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; + $trace =~ +s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; + $trace =~ +s/(\n\s+\S+__ANON__[^\n]+)?\n\s+eval[^\n]+\n\s+Error::subs::run_clauses[^\n]+\n\s+Error::subs::try[^\n]+(?=\n)//sog; my @callstack = split( m/\n/, $trace ); return @callstack; } @@ -532,26 +592,29 @@ my $old_WARN; sub DEATH { - my ( $e ) = @_; + my ($e) = @_; - local $SIG{__DIE__} = $old_DIE if( defined $old_DIE ); + local $SIG{__DIE__} = $old_DIE if ( defined $old_DIE ); die @_ if $^S; my ( $etype, $message, $location, @callstack ); - if ( ref($e) && $e->isa( "Error" ) ) { - $etype = "exception of type " . ref( $e ); - $message = $e->text; - $location = $e->file . ":" . $e->line; + if ( ref($e) && $e->isa("Error") ) + { + $etype = "exception of type " . ref($e); + $message = $e->text; + $location = $e->file . ":" . $e->line; @callstack = split( m/\n/, $e->stacktrace ); } - else { + else + { # Don't apply subsequent layer of message formatting - die $e if( $e =~ m/^\nUnhandled perl error caught at toplevel:\n\n/ ); + die $e if ( $e =~ m/^\nUnhandled perl error caught at toplevel:\n\n/ ); $etype = "perl error"; my $stackdepth = 0; - while( caller( $stackdepth ) =~ m/^Error(?:$|::)/ ) { - $stackdepth++ + while ( caller($stackdepth) =~ m/^Error(?:$|::)/ ) + { + $stackdepth++; } @callstack = gen_callstack( $stackdepth + 1 ); @@ -559,39 +622,43 @@ sub DEATH $message = "$e"; chomp $message; - if ( $message =~ s/ at (.*?) line (\d+)\.$// ) { + if ( $message =~ s/ at (.*?) line (\d+)\.$// ) + { $location = $1 . ":" . $2; } - else { - my @caller = caller( $stackdepth ); + else + { + my @caller = caller($stackdepth); $location = $caller[1] . ":" . $caller[2]; } } shift @callstack; + # Do it this way in case there are no elements; we don't print a spurious \n - my $callstack = join( "", map { "$_\n"} @callstack ); + my $callstack = join( "", map { "$_\n" } @callstack ); - die "\nUnhandled $etype caught at toplevel:\n\n $message\n\nThrown from: $location\n\nFull stack trace:\n\n$callstack\n"; + die +"\nUnhandled $etype caught at toplevel:\n\n $message\n\nThrown from: $location\n\nFull stack trace:\n\n$callstack\n"; } sub TAXES { - my ( $message ) = @_; + my ($message) = @_; - local $SIG{__WARN__} = $old_WARN if( defined $old_WARN ); + local $SIG{__WARN__} = $old_WARN if ( defined $old_WARN ); $message =~ s/ at .*? line \d+\.$//; chomp $message; - my @callstack = gen_callstack( 1 ); - my $location = shift @callstack; + my @callstack = gen_callstack(1); + my $location = shift @callstack; # $location already starts in a leading space $message .= $location; # Do it this way in case there are no elements; we don't print a spurious \n - my $callstack = join( "", map { "$_\n"} @callstack ); + my $callstack = join( "", map { "$_\n" } @callstack ); warn "$message:\n$callstack"; } @@ -609,16 +676,17 @@ sub import __END__ +=pod + +=encoding UTF-8 + =head1 NAME -Error - Error/exception handling in an OO-ish way +Error -=head1 WARNING +=head1 VERSION -Using the "Error" module is B due to the black-magical -nature of its syntactic sugar, which often tends to break. Its maintainers -have stopped actively writing code that uses it, and discourage people -from doing so. See the "SEE ALSO" section below for better recommendations. +version 0.17027 =head1 SYNOPSIS @@ -631,7 +699,7 @@ from doing so. See the "SEE ALSO" section below for better recommendations. record Error::Simple("A simple error") and return; } - + unlink($file) or throw Error::Simple("$file: $!",$!); try { @@ -668,6 +736,21 @@ subsequent catch, or can simply be recorded. Errors in the class C should not be thrown directly, but the user should throw errors from a sub-class of C. +=head1 NAME + +Error - Error/exception handling in an OO-ish way + +=head1 VERSION + +version 0.17027 + +=head1 WARNING + +Using the "Error" module is B due to the black-magical +nature of its syntactic sugar, which often tends to break. Its maintainers +have stopped actively writing code that uses it, and discourage people +from doing so. See the "SEE ALSO" section below for better recommendations. + =head1 PROCEDURAL INTERFACE C exports subroutines to perform exception handling. These will @@ -822,8 +905,6 @@ package or uncaught errors generated using C will be reported. $Error->flush; -=cut - =back =head2 OBJECT METHODS @@ -899,20 +980,19 @@ is a numeric value. These values are what will be returned by the overload methods. If the text value ends with C as $@ strings do, then -this infomation will be used to set the C<-file> and C<-line> arguments +this information will be used to set the C<-file> and C<-line> arguments of the error object. This class is used internally if an eval'd block die's with an error that is a plain string. (Unless C<$Error::ObjectifyCallback> is modified) - =head1 $Error::ObjectifyCallback This variable holds a reference to a subroutine that converts errors that are plain strings to objects. It is used by Error.pm to convert textual -errors to objects, and can be overrided by the user. +errors to objects, and can be overridden by the user. -It accepts a single argument which is a hash reference to named parameters. +It accepts a single argument which is a hash reference to named parameters. Currently the only named parameter passed is C<'text'> which is the text of the error, but others may be available in the future. @@ -933,8 +1013,6 @@ class MyError::Bar by default: # Error handling here. } -=cut - =head1 MESSAGE HANDLERS C also provides handlers to extend the output of the C perl @@ -987,8 +1065,6 @@ into main::inner('undef') called at examples/warndie.pl line 20 main::outer('undef') called at examples/warndie.pl line 23 -=cut - =head1 SEE ALSO See L for a different module providing Object-Oriented @@ -1000,7 +1076,7 @@ on what you want. (Because Error's syntactic sugar tends to break.) L aims to combine L and L "with correct stringification". -L and L are similar in concept to Error.pm only providing +L and L are similar in concept to Error.pm only providing a syntax that hopefully breaks less. =head1 KNOWN BUGS @@ -1019,7 +1095,7 @@ C<:warndie> handlers added by Paul Evans =head1 MAINTAINER -Shlomi Fish +Shlomi Fish, L . =head1 PAST MAINTAINERS @@ -1031,5 +1107,125 @@ Copyright (c) 1997-8 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut +=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan + +=head1 SUPPORT + +=head2 Websites + +The following websites have more information about this module, and may be of help to you. As always, +in addition to those websites please use your favorite search engine to discover more resources. + +=over 4 + +=item * + +MetaCPAN + +A modern, open-source CPAN search engine, useful to view POD in HTML format. + +L + +=item * + +Search CPAN + +The default CPAN search engine, useful to view POD in HTML format. + +L + +=item * + +RT: CPAN's Bug Tracker + +The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. + +L +=item * + +AnnoCPAN + +The AnnoCPAN is a website that allows community annotations of Perl module documentation. + +L + +=item * + +CPAN Ratings + +The CPAN Ratings is a website that allows community ratings and reviews of Perl modules. + +L + +=item * + +CPANTS + +The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. + +L + +=item * + +CPAN Testers + +The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. + +L + +=item * + +CPAN Testers Matrix + +The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. + +L + +=item * + +CPAN Testers Dependencies + +The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. + +L + +=back + +=head2 Bugs / Feature Requests + +Please report any bugs or feature requests by email to C, or through +the web interface at L. You will be automatically notified of any +progress on the request by the system. + +=head2 Source Code + +The code is open to the world, and available for you to hack on. Please feel free to browse it and play +with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull +from your repository :) + +L + + git clone https://bitbucket.org/shlomif/perl-error.pm + +=head1 AUTHOR + +Shlomi Fish ( http://www.shlomifish.org/ ) + +=head1 BUGS + +Please report any bugs or feature requests on the bugtracker website +L + +When submitting a bug or request, please include a test-file or a +patch to an existing test-file that illustrates the bug or desired +feature. + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2018 by Shlomi Fish ( http://www.shlomifish.org/ ). + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Error/Simple.pm b/lib/Error/Simple.pm index a4ba72f..6f74930 100644 --- a/lib/Error/Simple.pm +++ b/lib/Error/Simple.pm @@ -1,20 +1,33 @@ -# Error.pm +# Error/Simple.pm # -# Copyright (c) 2006 Shlomi Fish . All rights reserved. -# This program is free software; you can redistribute it and/or -# modify it under the terms of the MIT/X11 license. - +# Copyright (c) 2006 Shlomi Fish . +# This file is free software; you can redistribute it and/or +# modify it under the terms of the MIT/X11 license (whereas the licence +# of the Error distribution as a whole is the GPLv1+ and the Artistic +# licence). + +package Error::Simple; +$Error::Simple::VERSION = '0.17027'; use strict; use warnings; use Error; 1; + __END__ +=pod + +=encoding UTF-8 + =head1 NAME -Error::Simple - the simple error sub-class of Error +Error::Simple + +=head1 VERSION + +version 0.17027 =head1 SYNOPSIS @@ -29,6 +42,14 @@ The only purpose of this module is to allow one to say: and the only thing it does is "use" Error.pm. Refer to the documentation of L for more information about Error::Simple. +=head1 NAME + +Error::Simple - the simple error sub-class of Error + +=head1 VERSION + +version 0.17027 + =head1 METHODS =head2 Error::Simple->new($text [, $value]) @@ -46,9 +67,131 @@ None. =head1 AUTHORS -Shlomi Fish ( C<< shlomif@iglu.org.il >> ) +Shlomi Fish ( L ) =head1 SEE ALSO L +=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan + +=head1 SUPPORT + +=head2 Websites + +The following websites have more information about this module, and may be of help to you. As always, +in addition to those websites please use your favorite search engine to discover more resources. + +=over 4 + +=item * + +MetaCPAN + +A modern, open-source CPAN search engine, useful to view POD in HTML format. + +L + +=item * + +Search CPAN + +The default CPAN search engine, useful to view POD in HTML format. + +L + +=item * + +RT: CPAN's Bug Tracker + +The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. + +L + +=item * + +AnnoCPAN + +The AnnoCPAN is a website that allows community annotations of Perl module documentation. + +L + +=item * + +CPAN Ratings + +The CPAN Ratings is a website that allows community ratings and reviews of Perl modules. + +L + +=item * + +CPANTS + +The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. + +L + +=item * + +CPAN Testers + +The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. + +L + +=item * + +CPAN Testers Matrix + +The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. + +L + +=item * + +CPAN Testers Dependencies + +The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. + +L + +=back + +=head2 Bugs / Feature Requests + +Please report any bugs or feature requests by email to C, or through +the web interface at L. You will be automatically notified of any +progress on the request by the system. + +=head2 Source Code + +The code is open to the world, and available for you to hack on. Please feel free to browse it and play +with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull +from your repository :) + +L + + git clone https://bitbucket.org/shlomif/perl-error.pm + +=head1 AUTHOR + +Shlomi Fish ( http://www.shlomifish.org/ ) + +=head1 BUGS + +Please report any bugs or feature requests on the bugtracker website +L + +When submitting a bug or request, please include a test-file or a +patch to an existing test-file that illustrates the bug or desired +feature. + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2018 by Shlomi Fish ( http://www.shlomifish.org/ ). + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/scripts/bump-version-number.pl b/scripts/bump-version-number.pl new file mode 100644 index 0000000..4fb7cf8 --- /dev/null +++ b/scripts/bump-version-number.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use File::Find::Object; +use IO::All; + +my $tree = File::Find::Object->new({}, 'lib/'); + +my $version_n = shift(@ARGV); + +if (!defined($version_n)) +{ + die "Specify version number as an argument! bump-version-number.pl '0.0.1'"; +} + +sub process_file +{ + # The filename. + my ($r) = @_; + + my @lines = io->file($r)->getlines(); + foreach (@lines) + { + s#(\$VERSION = "|^Version )\d+\.\d+(?:\.\d+)?("|)#$1 . $version_n . $2#e; + } + io->file($r)->print( + @lines + ); +} + +while (my $r = $tree->next()) { + if ($r =~ m{/\.(?:svn|hg|git)\z}) + { + $tree->prune(); + } + elsif ($r =~ m{\.pm\z}) + { + process_file($r); + } +} + diff --git a/t/00-compile.t b/t/00-compile.t new file mode 100644 index 0000000..826f7e3 --- /dev/null +++ b/t/00-compile.t @@ -0,0 +1,61 @@ +use 5.006; +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 + +use Test::More; + +plan tests => 2 + ($ENV{AUTHOR_TESTING} ? 1 : 0); + +my @module_files = ( + 'Error.pm', + 'Error/Simple.pm' +); + + + +# no fake home requested + +my @switches = ( + -d 'blib' ? '-Mblib' : '-Ilib', +); + +use File::Spec; +use IPC::Open3; +use IO::Handle; + +open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; + +my @warnings; +for my $lib (@module_files) +{ + # see L + my $stderr = IO::Handle->new; + + diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } + $^X, @switches, '-e', "require q[$lib]")) + if $ENV{PERL_COMPILE_TEST_DEBUG}; + + my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); + binmode $stderr, ':crlf' if $^O eq 'MSWin32'; + my @_warnings = <$stderr>; + waitpid($pid, 0); + is($?, 0, "$lib loaded ok"); + + shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ + and not eval { +require blib; blib->VERSION('1.01') }; + + if (@_warnings) + { + warn @_warnings; + push @warnings, @_warnings; + } +} + + + +is(scalar(@warnings), 0, 'no warnings found') + or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; + + diff --git a/t/01throw.t b/t/01throw.t index a1bdba2..cc3e044 100644 --- a/t/01throw.t +++ b/t/01throw.t @@ -1,4 +1,7 @@ +use strict; +use warnings; + use Error qw(:try); print "1..4\n"; @@ -20,6 +23,6 @@ finally { print "ok 3\n"; }; -$err = prior Error; +my $err = prior Error; print "ok ",2+$err,"\n";; diff --git a/t/02order.t b/t/02order.t index 7d1e59d..f0e3d1d 100644 --- a/t/02order.t +++ b/t/02order.t @@ -1,47 +1,61 @@ +use strict; +use warnings; + use Error qw(:try); @Error::Fatal::ISA = qw(Error); print "1..6\n"; -$num = try { - try { - try { - throw Error::Simple("ok 1\n"); - } - catch Error::Simple with { - my $err = shift; - print $err; - - throw Error::Fatal(-value => 4); - - print "not ok 3\n"; - } - catch Error::Fatal with { - exit(1); - } - finally { - print "ok 2\n"; - }; - } finally { - print "ok 3\n"; +my $num = try +{ + try + { + try + { + throw Error::Simple("ok 1\n"); + } + catch Error::Simple with + { + my $err = shift; + print $err; + + throw Error::Fatal( -value => 4 ); + + print "not ok 3\n"; + } + catch Error::Fatal with + { + exit(1); + } + finally + { + print "ok 2\n"; + }; + } + finally + { + print "ok 3\n"; }; } -catch Error::Fatal with { - my $err = shift; +catch Error::Fatal with +{ + my $err = shift; my $more = shift; $$more = 1; - print "ok ",0+$err,"\n"; + print "ok ", 0 + $err, "\n"; } -catch Error::Fatal with { +catch Error::Fatal with +{ my $err = shift; - print "ok ",1+$err,"\n"; + print "ok ", 1 + $err, "\n"; return 6; } -catch Error::Fatal with { +catch Error::Fatal with +{ my $err = shift; - print "not ok ",2+$err,"\n"; + print "not ok ", 2 + $err, "\n"; }; -print "ok ",$num,"\n"; +print "ok ", $num, "\n"; diff --git a/t/05text-errors-with-file-handles.t b/t/05text-errors-with-file-handles.t index dd36b33..6f05818 100644 --- a/t/05text-errors-with-file-handles.t +++ b/t/05text-errors-with-file-handles.t @@ -45,7 +45,7 @@ ok($ok, "Not MyError::Foo"); ok($err->isa("Error::Simple"), "Testing"); # TEST -is($err->{-line}, 16, "Testing for correct line number"); +is($err->{-line}, 19, "Testing for correct line number"); # TEST ok(($err->{-file} =~ m{MyDie\.pm$}), "Testing for correct module"); diff --git a/t/06customize-text-throw.t b/t/06customize-text-throw.t index 26eb523..bdbea96 100644 --- a/t/06customize-text-throw.t +++ b/t/06customize-text-throw.t @@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; +use warnings; use Test::More tests => 3; diff --git a/t/07try-in-obj-destructor.t b/t/07try-in-obj-destructor.t index b15bff2..89275a5 100644 --- a/t/07try-in-obj-destructor.t +++ b/t/07try-in-obj-destructor.t @@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; +use warnings; use Test::More tests => 1; diff --git a/t/08warndie.t b/t/08warndie.t index 205c6e1..530af48 100644 --- a/t/08warndie.t +++ b/t/08warndie.t @@ -76,7 +76,7 @@ run_kid { my ( $linea, $lineb ) = ( $line + 2, $line + 3 ); like( $s, qr/^A warning at $file line $linea\.?: \tmain::__ANON__\(\) called at $file line $linekid -\tmain::run_kid\('CODE\(0x[0-9a-f]+\)'\) called at $file line $lineb +\tmain::run_kid\('?CODE\(0x[0-9a-f]+\)'?\) called at $file line $lineb $/, "warn \\n-terminated STDERR" ); is( $felloffcode, 1, "warn \\n-terminated felloffcode" ); @@ -88,7 +88,7 @@ run_kid { ( $linea, $lineb ) = ( $line + 2, $line + 3 ); like( $s, qr/^A warning at $file line $linea\.?: \tmain::__ANON__\(\) called at $file line $linekid -\tmain::run_kid\('CODE\(0x[0-9a-f]+\)'\) called at $file line $lineb +\tmain::run_kid\('?CODE\(0x[0-9a-f]+\)'?\) called at $file line $lineb $/, "warn unterminated STDERR" ); is( $felloffcode, 1, "warn unterminated felloffcode" ); @@ -108,7 +108,7 @@ Thrown from: $file:$linea Full stack trace: \tmain::__ANON__\(\) called at $file line $linekid -\tmain::run_kid\('CODE\(0x[0-9a-f]+\)'\) called at $file line $lineb +\tmain::run_kid\('?CODE\(0x[0-9a-f]+\)'?\) called at $file line $lineb $/, "die \\n-terminated STDERR" ); is( $felloffcode, 0, "die \\n-terminated felloffcode" ); @@ -129,7 +129,7 @@ Thrown from: $file:$linea Full stack trace: \tmain::__ANON__\(\) called at $file line $linekid -\tmain::run_kid\('CODE\(0x[0-9a-f]+\)'\) called at $file line $lineb +\tmain::run_kid\('?CODE\(0x[0-9a-f]+\)'?\) called at $file line $lineb $/, "die unterminated STDERR" ); is( $felloffcode, 0, "die unterminated felloffcode" ); @@ -150,7 +150,7 @@ Thrown from: $file:$linea Full stack trace: \tmain::__ANON__\(\) called at $file line $linekid -\tmain::run_kid\('CODE\(0x[0-9a-f]+\)'\) called at $file line $lineb +\tmain::run_kid\('?CODE\(0x[0-9a-f]+\)'?\) called at $file line $lineb $/, "Error STDOUT" ); is( $felloffcode, 0, "Error felloffcode" ); @@ -191,7 +191,7 @@ run_kid { ( $linea, $lineb ) = ( $line + 2, $line + 3 ); like( $s, qr/^My custom warning here: A warning at $file line $linea\.?: \tmain::__ANON__\(\) called at $file line $linekid -\tmain::run_kid\('CODE\(0x[0-9a-f]+\)'\) called at $file line $lineb +\tmain::run_kid\('?CODE\(0x[0-9a-f]+\)'?\) called at $file line $lineb $/, "Custom warn STDERR" ); is( $felloffcode, 1, "Custom warn felloffcode" ); @@ -200,8 +200,9 @@ run_kid { die "An error"; }; +my $WS = ' '; ( $linea, $lineb ) = ( $line + 2, $line + 3 ); -like( $s, qr/^My custom death here: +like( $s, qr/^My custom death here:$WS Unhandled perl error caught at toplevel: An error @@ -211,7 +212,7 @@ Thrown from: $file:$linea Full stack trace: \tmain::__ANON__\(\) called at $file line $linekid -\tmain::run_kid\('CODE\(0x[0-9a-f]+\)'\) called at $file line $lineb +\tmain::run_kid\('?CODE\(0x[0-9a-f]+\)'?\) called at $file line $lineb $/, "Custom die STDERR" ); is( $felloffcode, 0, "Custom die felloffcode" ); diff --git a/t/10throw-in-catch.t b/t/10throw-in-catch.t index 7d2af3e..eb25573 100644 --- a/t/10throw-in-catch.t +++ b/t/10throw-in-catch.t @@ -20,7 +20,7 @@ catch Error::Simple with { $error = $@; # TEST -ok (scalar($error =~ /^A-Lovely-Day/), +ok (scalar($error =~ /^A-Lovely-Day/), "Error thrown in the catch clause is registered" ); @@ -35,7 +35,7 @@ otherwise { $error = $@; # TEST -ok (scalar($error =~ /^Had-the-ancient/), +ok (scalar($error =~ /^Had-the-ancient/), "Error thrown in the otherwise clause is registered" ); diff --git a/t/11rethrow.t b/t/11rethrow.t index 227bca5..fdce0bb 100644 --- a/t/11rethrow.t +++ b/t/11rethrow.t @@ -1,50 +1,61 @@ #!/usr/bin/perl +use strict; +use warnings; + use Error qw(:try); use Test::More tests => 4; -try { - try { die "inner" } - catch Error::Simple with { die "foobar" }; +try +{ + try { die "inner" } + catch Error::Simple with { die "foobar" }; } otherwise { - my $err = shift; + my $err = shift; + # TEST - ok (scalar($err =~ /foobar/), "Error rethrown"); + ok( scalar( $err =~ /foobar/ ), "Error rethrown" ); }; -try { - try { die "inner" } - catch Error::Simple with { throw Error::Simple "foobar" }; +try +{ + try { die "inner" } + catch Error::Simple with { throw Error::Simple "foobar" }; } otherwise { - my $err = shift; + my $err = shift; + # TEST - ok (scalar("$err" =~ /foobar/), "Thrown Error::Simple"); + ok( scalar( "$err" =~ /foobar/ ), "Thrown Error::Simple" ); }; -try { - try { die "inner" } - otherwise { die "foobar" }; +try +{ + try { die "inner" } + otherwise { die "foobar" }; } otherwise { my $err = shift; + # TEST - ok (scalar("$err" =~ /foobar/), "die foobar"); + ok( scalar( "$err" =~ /foobar/ ), "die foobar" ); }; -try { - try { die "inner" } - catch Error::Simple with { throw Error::Simple "foobar" }; +try +{ + try { die "inner" } + catch Error::Simple with { throw Error::Simple "foobar" }; } otherwise { - my $err = shift; + my $err = shift; + # TEST - ok (scalar($err =~ /foobar/), "throw Error::Simple"); + ok( scalar( $err =~ /foobar/ ), "throw Error::Simple" ); }; 1; diff --git a/t/14Error-Simple-VERSION.t b/t/14Error-Simple-VERSION.t new file mode 100644 index 0000000..968f42a --- /dev/null +++ b/t/14Error-Simple-VERSION.t @@ -0,0 +1,18 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 1; + +use vars qw($VERSION); + +$VERSION = '0.001'; + +require Error::Simple; + +# TEST +is ($VERSION, '0.001', "Testing that the VERSION was not overrided"); + +1; + diff --git a/t/lib/MyDie.pm b/t/lib/MyDie.pm index 21205c8..c4b7222 100644 --- a/t/lib/MyDie.pm +++ b/t/lib/MyDie.pm @@ -1,5 +1,8 @@ package MyDie; +use strict; +use warnings; + sub mydie { local *I; diff --git a/t/pod-coverage.t b/t/pod-coverage.t deleted file mode 100644 index 703f91d..0000000 --- a/t/pod-coverage.t +++ /dev/null @@ -1,6 +0,0 @@ -#!perl -T - -use Test::More; -eval "use Test::Pod::Coverage 1.04"; -plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; -all_pod_coverage_ok(); diff --git a/t/pod.t b/t/pod.t deleted file mode 100644 index 976d7cd..0000000 --- a/t/pod.t +++ /dev/null @@ -1,6 +0,0 @@ -#!perl -T - -use Test::More; -eval "use Test::Pod 1.14"; -plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; -all_pod_files_ok(); diff --git a/weaver.ini b/weaver.ini new file mode 100644 index 0000000..21ba738 --- /dev/null +++ b/weaver.ini @@ -0,0 +1 @@ +[@SHLOMIF] diff --git a/xt/author/eol.t b/xt/author/eol.t new file mode 100644 index 0000000..20e6a16 --- /dev/null +++ b/xt/author/eol.t @@ -0,0 +1,31 @@ +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::EOL 0.19 + +use Test::More 0.88; +use Test::EOL; + +my @files = ( + 'lib/Error.pm', + 'lib/Error/Simple.pm', + 't/00-compile.t', + 't/01throw.t', + 't/02order.t', + 't/03throw-non-Error.t', + 't/04use-base-Error-Simple.t', + 't/05text-errors-with-file-handles.t', + 't/06customize-text-throw.t', + 't/07try-in-obj-destructor.t', + 't/08warndie.t', + 't/09dollar-at.t', + 't/10throw-in-catch.t', + 't/11rethrow.t', + 't/12wrong-error-var.t', + 't/13except-arg0.t', + 't/14Error-Simple-VERSION.t', + 't/lib/MyDie.pm' +); + +eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; +done_testing; diff --git a/xt/author/no-tabs.t b/xt/author/no-tabs.t new file mode 100644 index 0000000..f8b5d53 --- /dev/null +++ b/xt/author/no-tabs.t @@ -0,0 +1,31 @@ +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 + +use Test::More 0.88; +use Test::NoTabs; + +my @files = ( + 'lib/Error.pm', + 'lib/Error/Simple.pm', + 't/00-compile.t', + 't/01throw.t', + 't/02order.t', + 't/03throw-non-Error.t', + 't/04use-base-Error-Simple.t', + 't/05text-errors-with-file-handles.t', + 't/06customize-text-throw.t', + 't/07try-in-obj-destructor.t', + 't/08warndie.t', + 't/09dollar-at.t', + 't/10throw-in-catch.t', + 't/11rethrow.t', + 't/12wrong-error-var.t', + 't/13except-arg0.t', + 't/14Error-Simple-VERSION.t', + 't/lib/MyDie.pm' +); + +notabs_ok($_) foreach @files; +done_testing; diff --git a/xt/author/pod-coverage.t b/xt/author/pod-coverage.t new file mode 100644 index 0000000..66b3b64 --- /dev/null +++ b/xt/author/pod-coverage.t @@ -0,0 +1,7 @@ +#!perl +# This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. + +use Test::Pod::Coverage 1.08; +use Pod::Coverage::TrustPod; + +all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); diff --git a/xt/author/pod-syntax.t b/xt/author/pod-syntax.t new file mode 100644 index 0000000..e563e5d --- /dev/null +++ b/xt/author/pod-syntax.t @@ -0,0 +1,7 @@ +#!perl +# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. +use strict; use warnings; +use Test::More; +use Test::Pod 1.41; + +all_pod_files_ok(); diff --git a/xt/release/cpan-changes.t b/xt/release/cpan-changes.t new file mode 100644 index 0000000..286005a --- /dev/null +++ b/xt/release/cpan-changes.t @@ -0,0 +1,10 @@ +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012 + +use Test::More 0.96 tests => 1; +use Test::CPAN::Changes; +subtest 'changes_ok' => sub { + changes_file_ok('Changes'); +}; diff --git a/xt/release/trailing-space.t b/xt/release/trailing-space.t new file mode 100644 index 0000000..e385619 --- /dev/null +++ b/xt/release/trailing-space.t @@ -0,0 +1,30 @@ +#!perl + +use strict; +use warnings; + +use Test::More; + +eval "use Test::TrailingSpace"; +if ($@) +{ + plan skip_all => "Test::TrailingSpace required for trailing space test."; +} +else +{ + plan tests => 1; +} + +# TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly +# some other stuff. +my $finder = Test::TrailingSpace->new( + { + root => '.', + filename_regex => qr#(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z#, + }, +); + +# TEST +$finder->no_trailing_space( + "No trailing space was found." +); -- 2.34.1