Exception and class handling for getLastPost in the Thread. Update a test accordingly.
This commit is contained in:
parent
4056d7019e
commit
9e50f5e8c2
2 changed files with 7 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue