- removed references to Time::Piece::* modules. The default date behavior has burned us a few time now (most notably in the Session code), so we need to be explicit about our dates and date comparisons. - standardized how we make our calls to Date::Manip - implemented a logError method and use it replace all old STDERR output references - manage_categories cleanup: show product name in branch listing, making it easier to find which branch you're looking for when many branches have the same name. Do the same thing for opsyses and platforms. - added Litmus::Utils::sanitize() for processing CGI input git-svn-id: svn://10.0.0.236/trunk@252331 18797224-902f-48f8-a5cc-f745e15eee43
96 lines
2.4 KiB
Perl
Executable File
96 lines
2.4 KiB
Perl
Executable File
# -*- mode: cperl; c-basic-offset: 8; indent-tabs-mode: nil; -*-
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
# Version: MPL 1.1
|
|
#
|
|
# 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 Litmus.
|
|
#
|
|
# The Initial Developer of the Original Code is
|
|
# the Mozilla Corporation.
|
|
# Portions created by the Initial Developer are Copyright (C) 2006
|
|
# the Initial Developer. All Rights Reserved.
|
|
#
|
|
# Contributor(s):
|
|
# Chris Cooper <ccooper@deadsquid.com>
|
|
# Zach Lipton <zach@zachlipton.com>
|
|
#
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
=cut
|
|
|
|
# General error reporting
|
|
|
|
package Litmus::Error;
|
|
|
|
use strict;
|
|
|
|
our @ISA = qw(Exporter);
|
|
@Litmus::Error::EXPORT = qw(
|
|
basicError
|
|
invalidInputError
|
|
internalError
|
|
lastDitchError
|
|
);
|
|
|
|
# just a general run of the mill error
|
|
sub basicError {
|
|
my $message = shift;
|
|
_doError($message);
|
|
exit;
|
|
}
|
|
|
|
# used to alert the user when an unexpected input value is found
|
|
sub invalidInputError($) {
|
|
my $message = shift;
|
|
_doError("Invalid Input - $message");
|
|
exit;
|
|
}
|
|
|
|
sub internalError($) {
|
|
my $message = shift;
|
|
_doError("Litmus has suffered an internal error - $message");
|
|
exit;
|
|
}
|
|
|
|
# an error type that does not use a template error message. Used if we
|
|
# can't even process the error template.
|
|
sub lastDitchError($) {
|
|
my $message = shift;
|
|
print "Error - Litmus has suffered a serious fatal internal error - $message";
|
|
exit;
|
|
}
|
|
|
|
sub _doError($) {
|
|
my $message = shift;
|
|
my $vars = {
|
|
message => $message,
|
|
};
|
|
Litmus->template()->process("error/error.html.tmpl", $vars) ||
|
|
lastDitchError(Litmus->template()->error());
|
|
}
|
|
|
|
# logError - make it easier to change how and where we log
|
|
#
|
|
# $message - the error message to be logged
|
|
# @caller_details - array in the format returned by caller(#)
|
|
sub logError($@) {
|
|
my $message = shift;
|
|
my @caller_details = @_;
|
|
|
|
print STDERR join('|',@caller_details[1..3]) . ' - ' . $message ."\n";
|
|
}
|
|
|
|
1;
|