summaryrefslogtreecommitdiffstats
path: root/extensions/GitHubAuth/lib/Client
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2015-03-04 04:27:15 +0100
committerDylan William Hardison <dylan@hardison.net>2015-04-03 00:21:08 +0200
commitc0d00a57eebb31d3e2cdef0ebb9219ebe2fe2bab (patch)
treee6c6eb07c7348e086f1ed6de54de829e806dda05 /extensions/GitHubAuth/lib/Client
parent1317be9bb70dbb945fa82d0d1bd8548c83c86ebe (diff)
downloadbugzilla-c0d00a57eebb31d3e2cdef0ebb9219ebe2fe2bab.tar.gz
bugzilla-c0d00a57eebb31d3e2cdef0ebb9219ebe2fe2bab.tar.xz
Github Auth Extension
Diffstat (limited to 'extensions/GitHubAuth/lib/Client')
-rw-r--r--extensions/GitHubAuth/lib/Client/Error.pm53
1 files changed, 53 insertions, 0 deletions
diff --git a/extensions/GitHubAuth/lib/Client/Error.pm b/extensions/GitHubAuth/lib/Client/Error.pm
new file mode 100644
index 000000000..358df6938
--- /dev/null
+++ b/extensions/GitHubAuth/lib/Client/Error.pm
@@ -0,0 +1,53 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Extension::GitHubAuth::Client::Error;
+
+use strict;
+use warnings;
+
+use Bugzilla::Error ();
+
+use base qw(Exporter);
+use fields qw(type error vars);
+
+our @EXPORT = qw(ThrowUserError ThrowCodeError);
+our $USE_EXCEPTION_OBJECTS = 0;
+
+sub _new {
+ my ($class, $type, $error, $vars) = @_;
+ my $self = $class->fields::new();
+ $self->{type} = $type;
+ $self->{error} = $error;
+ $self->{vars} = $vars // {};
+
+ return $self;
+}
+
+sub type { $_[0]->{type} }
+sub error { $_[0]->{error} }
+sub vars { $_[0]->{vars} }
+
+sub ThrowUserError {
+ if ($USE_EXCEPTION_OBJECTS) {
+ die __PACKAGE__->_new('user', @_);
+ }
+ else {
+ Bugzilla::Error::ThrowUserError(@_);
+ }
+}
+
+sub ThrowCodeError {
+ if ($USE_EXCEPTION_OBJECTS) {
+ die __PACKAGE__->_new('code', @_);
+ }
+ else {
+ Bugzilla::Error::ThrowCodeError(@_);
+ }
+}
+
+1;