CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Detect error

 



chebarbudo
New User

Jul 26, 2017, 7:30 AM

Post #1 of 2 (630 views)
Detect error Can't Post

Hi there,

Today I wrote my first Perl script. Not that I want to go deep into it. But we just moved to OTRS and Perl is the way to play with it. So I wrote the following scritp:


Code
#!/usr/bin/perl 
use strict;
use warnings;
use utf8;

use Kernel::System::ObjectManager;
local $Kernel::OM = Kernel::System::ObjectManager->new();
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');


my $Success = $TicketObject->TicketMerge(
MainTicketID => 1673,
MergeTicketID => 1689123,
UserID => 1,
) || die();


In this specific scenario, ticket #1689123 does not exist and the function TicketMerge fails outputing many error messages. So I'm expecting the whole script to exit with error but it does not:

Code
$ perl myscript; echo $? 
0


How can I make sure that if the function TicketMerge fails, the whole script fails and we know it?

Regards
Santiago


Zhris
Enthusiast

Jul 27, 2017, 5:22 PM

Post #2 of 2 (601 views)
Re: [chebarbudo] Detect error [In reply to] Can't Post

Hi,

From looking over Kernel::System::Ticket's TicketMerge method it looks as though your code is fine, it returns false if any issue arises otherwise true. You mention that the TicketMerge method fails and outputs various error messages, could you possibly provide the complete output as these messages may provide important clues. As it stands, the behaviour you report doesn't correlate with the modules code.

Chris

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives