From e0db56e755e94e07677faa3729a4affe38a3ce18 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Wed, 28 May 2008 03:08:59 +0000 Subject: Bug 435507: Provide a method of hooking the WebService error codes Patch By Max Kanat-Alexander r=ghendricks, a=mkanat --- extensions/example/code/webservice-error_codes.pl | 25 ++++++++++++++++++++++ extensions/example/lib/WSExample.pm | 4 +++- .../template/en/global/user-error-errors.html.tmpl | 12 +++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 extensions/example/code/webservice-error_codes.pl create mode 100644 extensions/example/template/en/global/user-error-errors.html.tmpl (limited to 'extensions') diff --git a/extensions/example/code/webservice-error_codes.pl b/extensions/example/code/webservice-error_codes.pl new file mode 100644 index 000000000..94c4c52fc --- /dev/null +++ b/extensions/example/code/webservice-error_codes.pl @@ -0,0 +1,25 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Bugzilla Bug Tracking System. +# +# The Initial Developer of the Original Code is Everything Solved, Inc. +# Portions created by Everything Solved, Inc. are Copyright (C) 2008 +# Everything Solved, Inc. All Rights Reserved. +# +# Contributor(s): Max Kanat-Alexander + +use strict; +use warnings; +use Bugzilla; +my $error_map = Bugzilla->hook_args->{error_map}; +$error_map->{'example_my_error'} = 10001; diff --git a/extensions/example/lib/WSExample.pm b/extensions/example/lib/WSExample.pm index ced4c6d36..146867294 100644 --- a/extensions/example/lib/WSExample.pm +++ b/extensions/example/lib/WSExample.pm @@ -21,10 +21,12 @@ package extensions::example::lib::WSExample; use strict; use warnings; - use base qw(Bugzilla::WebService); +use Bugzilla::Error; # This can be called as Example.hello() from XML-RPC. sub hello { return 'Hello!'; } +sub throw_an_error { ThrowUserError('example_my_error') } + 1; diff --git a/extensions/example/template/en/global/user-error-errors.html.tmpl b/extensions/example/template/en/global/user-error-errors.html.tmpl new file mode 100644 index 000000000..df5a203dd --- /dev/null +++ b/extensions/example/template/en/global/user-error-errors.html.tmpl @@ -0,0 +1,12 @@ +[%# Note that error messages should generally be indented four spaces, like + # below, because when Bugzilla translates an error message into plain + # text, it takes four spaces off the beginning of the lines. + # + # Note also that I prefixed my error name with "example", the name of my + # extension, so that I wouldn't conflict with other error names in + # Bugzilla or other extensions. + #%] +[% IF error == "example_my_error" %] + [% title = "Example Error Title" %] + This is the error message! It contains some html. +[% END %] -- cgit v1.2.3-24-g4f1b