Skip to content

Commit

Permalink
Fixed error handling in invoker Ticket::Generic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jepf committed Dec 5, 2023
1 parent 2f50acf commit d3bdcd5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- 2023-11-30 Fixed URL for CustomerID in AgentTicketOverviewMedium. [#506](https://github.com/znuny/Znuny/issues/506)
- 2023-11-17 Pending dashboards now show all pending tickets.
- 2023-11-13 Added option 'send-timeout' to console command Maint::Email::MailQueue.
- 2023-10-25 Fixed error handling in invoker Ticket::Generic.

# 7.0.13 2023-11-15
- 2023-11-09 Added missing links to widget on CustomerUserInformationCenter: create phone ticket, create email ticket, switch to customer.
Expand Down
38 changes: 25 additions & 13 deletions Kernel/GenericInterface/Invoker/Ticket/Generic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,6 @@ sub HandleResponse {
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
my $ArticleObject = $Kernel::OM->Get('Kernel::System::Ticket::Article');

# if there was an error in the response, forward it
if ( !$Param{ResponseSuccess} ) {
if ( !IsStringWithData( $Param{ResponseErrorMessage} ) ) {
return $Self->{DebuggerObject}->Error(
Summary => 'Got response error, but no response error message!',
);
}
return {
Success => 0,
ErrorMessage => $Param{ResponseErrorMessage},
};
}

# Pass through response if no hash
if ( !IsHashRefWithData( $Param{Data} ) ) {
return {
Expand All @@ -189,6 +176,7 @@ sub HandleResponse {
};
}

# Set data and execute functions even in error case.
RESULT:
for my $Key ( sort keys %{ $Param{Data} } ) {

Expand Down Expand Up @@ -398,10 +386,34 @@ sub HandleResponse {
);
}

# if there was an error in the response, forward it
if ( !$Param{ResponseSuccess} ) {
if ( !IsStringWithData( $Param{ResponseErrorMessage} ) ) {
return $Self->{DebuggerObject}->Error(
Summary => 'Got response error, but no response error message!',
);
}
return {
Success => 0,
ErrorMessage => $Param{ResponseErrorMessage},
};
}

return {
Success => 1,
Data => $Param{Data},
};
}

sub HandleError {
my ( $Self, %Param ) = @_;

# Execute HandleResponse with error data because it might contain further tags
# to set data or execute functions (see HandleResponse above) in error case.
return $Self->HandleResponse(
ResponseSuccess => 0,
Data => $Param{Data},
);
}

1;

0 comments on commit d3bdcd5

Please sign in to comment.