fix error handling in SQL
This commit is contained in:
parent
8cd0f80bd4
commit
9c725aa237
2 changed files with 11 additions and 49 deletions
|
|
@ -15,50 +15,6 @@ package WebGUI::Exception;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Exception::Class (
|
||||
|
||||
'WebGUI::Error' => {
|
||||
description => "A general error occured.",
|
||||
},
|
||||
'WebGUI::Error::OverrideMe' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => 'This method should be overridden by subclasses.',
|
||||
},
|
||||
'WebGUI::Error::MethodNotFound' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => q|Called a method that doesn't exist.|,
|
||||
fields => 'method'
|
||||
},
|
||||
'WebGUI::Error::InvalidObject' => {
|
||||
isa => 'WebGUI::Error::InvalidParam',
|
||||
description => "Expected to get a reference to an object type that wasn't gotten.",
|
||||
fields => ["expected","got"],
|
||||
},
|
||||
'WebGUI::Error::InvalidParam' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "Expected to get a param we didn't get.",
|
||||
fields => ["param"],
|
||||
},
|
||||
'WebGUI::Error::ObjectNotFound' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "The object you were trying to retrieve does not exist.",
|
||||
fields => ["id"],
|
||||
},
|
||||
'WebGUI::Error::ObjectNotFound::Template' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "The template an asset was trying to retrieve does not exist.",
|
||||
fields => [qw/templateId assetId/],
|
||||
},
|
||||
'WebGUI::Error::InvalidFile' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "The file you have provided has errors.",
|
||||
fields => [qw{ brokenFile brokenLine }],
|
||||
},
|
||||
'WebGUI::Error::Template' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "A template has errors that prevent it from being processed.",
|
||||
},
|
||||
);
|
||||
|
||||
sub WebGUI::Error::full_message {
|
||||
my $self = shift;
|
||||
|
|
@ -318,13 +274,16 @@ use Exception::Class (
|
|||
description => "Couldn't establish a connection.",
|
||||
fields => [qw{ resource }],
|
||||
},
|
||||
|
||||
|
||||
'WebGUI::Error::Fatal' => {
|
||||
|
||||
'WebGUI::Error::Fatal' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => "Fatal error that should be shown to all site visitors.",
|
||||
},
|
||||
},
|
||||
|
||||
'WebGUI::Error::Database' => {
|
||||
isa => 'WebGUI::Error',
|
||||
description => 'A database error',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ use Tie::IxHash ();
|
|||
use Text::CSV_XS ();
|
||||
use WebGUI::Utility ();
|
||||
use WebGUI::SQL::ResultSet ();
|
||||
use WebGUI::Exception;
|
||||
use Scalar::Util ();
|
||||
use Try::Tiny;
|
||||
use namespace::clean;
|
||||
|
||||
|
|
@ -136,7 +138,7 @@ sub connect {
|
|||
$params->{AutoCommit} = 1;
|
||||
$params->{ShowErrorStatement} = 1;
|
||||
$params->{HandleError} = sub {
|
||||
$session->errorHandler->fatal(Carp::longmess(shift));
|
||||
WebGUI::Error::Database->throw(shift);
|
||||
};
|
||||
if ( ($class->parse_dsn($dsn))[1] eq 'mysql' ) {
|
||||
$params->{mysql_enable_utf8} = 1;
|
||||
|
|
@ -839,6 +841,7 @@ sub session {
|
|||
my $self = shift;
|
||||
if (@_) {
|
||||
$self->{private_webgui_session} = shift;
|
||||
Scalar::Util::weaken $self->{private_webgui_session};
|
||||
}
|
||||
return $self->{private_webgui_session};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue