Is it better to croak() or to die() when something bad happens in Perl?

后端 未结 6 1205
无人及你
无人及你 2021-02-18 22:12

perlcritic complaints that the following code, some boilerplate DBI stuff that works perfectly fine, should croak instead of die:

# Connect to database
my $db_ha         


        
6条回答
  •  太阳男子
    2021-02-18 22:42

    If we called the die and croak outside the function there is no difference between these functions.

    We can only find difference when we call die and croak within any other function.

    croak will gives information about the caller such as function name and line number..etc. die will give error and gives the line number where the error has occured.

提交回复
热议问题