What's broken about exceptions in Perl?

前端 未结 8 1161
孤城傲影
孤城傲影 2020-11-30 05:43

A discussion in another question got me wondering: what do other programming languages\' exception systems have that Perl\'s lacks?

Perl\'s built-in exceptions are a

8条回答
  •  [愿得一人]
    2020-11-30 06:30

    Don't use Exceptions for regular errors. Only Fatal problems that will stop the current execution should die. All other should be handled without die.

    Example: Parameter validation of called sub: Don't die at the first problem. Check all other parameters and then decide to stop by returning something or warn and correct the faulty parameters and proceed. That do in test or development mode. But possibly die in production mode. Let the application decide this.

    JPR (my CPAN login)

    Greetings from Sögel, Germany

提交回复
热议问题