-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item14237: Split exceptions into individual modules.
- Loading branch information
Showing
16 changed files
with
737 additions
and
327 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
=begin TML | ||
---+!! Class Foswiki::Exception::ASSERT | ||
This class is only for distinguishing ASSERT-generated exceptions. | ||
=cut | ||
|
||
package Foswiki::Exception::ASSERT; | ||
use Foswiki::Class; | ||
extends qw<Foswiki::Exception::Fatal>; | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
=begin TML | ||
---+!! Role Foswiki::Exception::Deadly | ||
As the name implies, exceptions with this role must result in application | ||
failure. | ||
=cut | ||
|
||
package Foswiki::Exception::Deadly; | ||
use Moo::Role; | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
=begin TML | ||
---+!! Class Foswiki::Exception::Engine | ||
Descendant of =%PERLDOC{"Foswiki::Exception::HTTPError"}%=. | ||
=cut | ||
|
||
package Foswiki::Exception::Engine; | ||
use Foswiki::Class; | ||
extends qw<Foswiki::Exception::HTTPError>; | ||
|
||
around BUILDARGS => sub { | ||
my $orig = shift; | ||
my $class = shift; | ||
my %params = @_; | ||
|
||
$params{status} //= 500; | ||
$params{header} //= 'Internal Server Error'; | ||
|
||
# Simulate the old Foswiki::EngineException behavior. | ||
$params{text} //= $params{response} | ||
if defined $params{response}; | ||
|
||
return $orig->( $class, %params ); | ||
}; | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
=begin TML | ||
---+!! Class Foswiki::Exception::Ext | ||
Base class for Foswiki::ExtManager-related exceptions. | ||
Generic. Must not be used directly. | ||
=cut | ||
|
||
package Foswiki::Exception::Ext; | ||
|
||
use Foswiki::Class; | ||
extends qw<Foswiki::Exception>; | ||
|
||
=begin TML | ||
---+++ ObjectAttribute extension => string | ||
Extension name. | ||
=cut | ||
|
||
has extension => ( | ||
is => 'ro', | ||
predicate => 1, | ||
|
||
# Coerce a ref into class name. | ||
coerce => sub { ref( $_[0] ) // $_[0] }, | ||
); | ||
|
||
around prepareText => sub { | ||
my $orig = shift; | ||
my $this = shift; | ||
|
||
return $this->has_extension | ||
? "Reported extension: " . $this->extension | ||
: "No reported extension"; | ||
}; | ||
|
||
# Preload exceptions | ||
#use Foswiki::Exception::Ext::BadName; | ||
#use Foswiki::Exception::Ext::Load; | ||
|
||
END { | ||
use Foswiki; | ||
for my $m (qw<BadName Load Last Restart>) { | ||
Foswiki::load_class("Foswiki::Exception::Ext::$m"); | ||
} | ||
} | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
package Foswiki::Exception::Ext::BadName; | ||
use Foswiki::Class; | ||
extends qw<Foswiki::Exception::Ext>; | ||
with qw<Foswiki::Exception::Deadly>; | ||
|
||
around prepareText => sub { | ||
my $orig = shift; | ||
my $this = shift; | ||
|
||
return "Bad extension name: '" . $this->extension . "'"; | ||
}; | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
package Foswiki::Exception::Ext::Flow; | ||
|
||
=begin TML | ||
---+!! Class Foswiki::Exception::Ext::Flow | ||
Base class of extension flow control events. Pure virtual, makes no sense on its | ||
own. | ||
=cut | ||
|
||
use Foswiki::Exception::Ext::Last; | ||
use Foswiki::Exception::Ext::Restart; | ||
|
||
use Foswiki::Class; | ||
extends qw<Foswiki::Exception::Ext>; | ||
with qw<Foswiki::Exception::Harmless>; | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
package Foswiki::Exception::Ext::Last; | ||
|
||
=begin TML | ||
---+!! Class Foswiki::Exception::Ext::Last | ||
Subclass of =Foswiki::Exception::Ext::Flow=. | ||
Inidicates that an extension is requesting to be the last in the execution line. | ||
=cut | ||
|
||
use Foswiki::Class; | ||
extends qw<Foswiki::Exception::Ext::Flow>; | ||
|
||
=begin TML | ||
---++ ObjectAttribute rc | ||
Return value of a method call. | ||
=cut | ||
|
||
has rc => ( is => 'rw', predicate => 1, ); | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
package Foswiki::Exception::Ext::Load; | ||
use Foswiki::Class; | ||
extends qw(Foswiki::Exception::Ext); | ||
|
||
has reason => ( | ||
is => 'rw', | ||
required => 1, | ||
); | ||
|
||
around prepareText => sub { | ||
my $orig = shift; | ||
my $this = shift; | ||
|
||
return | ||
"Failed to load extension '" | ||
. $this->extension . "': " | ||
. $this->reason; | ||
}; | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
Oops, something went wrong.