Exception and class handling for getLastPost in the Thread. Update a test accordingly.

This commit is contained in:
Colin Kuskie 2010-05-20 15:45:28 -07:00
parent 4056d7019e
commit 9e50f5e8c2
2 changed files with 7 additions and 7 deletions

View file

@ -410,12 +410,12 @@ Fetches the last post in this thread, otherwise, returns itself.
sub getLastPost {
my $self = shift;
my $lastPostId = $self->lastPostId;
my $lastPost;
if ($lastPostId) {
$lastPost = WebGUI::Asset::Post->newById($self->session, $lastPostId);
}
return $lastPost if (defined $lastPost);
return $self;
return $self unless $lastPostId;
my $lastPost = eval { WebGUI::Asset->newById($self->session, $lastPostId); };
if (Exception::Class->caught()) {
return $self;
}
return $lastPost;
}
#-------------------------------------------------------------------