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 Nov 29, 2023
1 parent c46b507 commit b8cc20c
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 @@ -5,6 +5,7 @@
- 2023-11-06 Sector Nord AG: Fixed CTRL+left click in ticket overviews. Thanks to Ziggy Trotter (@ZTrotter), Sector Nord AG. [PR#487](https://github.com/znuny/Znuny/pull/487)
- 2023-11-06 Fixed queue_id in ticket history for the initial ticket. Thanks to Tim Püttmanns (@tipue-dev), maxence. [PR#299](https://github.com/znuny/Znuny/pull/299)
- 2023-10-26 Added pagination for ArticlePages on AgentTicketZoom.
- 2023-10-25 Fixed error handling in invoker Ticket::Generic.
- 2023-10-23 Fixed used email address to decrypt S/MIME messages in Kernel::System::PostMaster::Filter::Decrypt.
- 2023-10-10 Updated CKEditor to version 4.22.1.
- 2023-09-29 Added optional caching to web service requests of dynamic field types WebserviceDropdown and WebserviceMultiselect.
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 b8cc20c

Please sign in to comment.