Throwing exceptions in a PHP Try Catch block

后端 未结 5 1925
情书的邮戳
情书的邮戳 2020-12-24 00:04

I have a PHP function in a Drupal 6 .module file. I am attempting to run initial variable validations prior to executing more intensive tasks (such as database queries). In

5条回答
  •  一整个雨季
    2020-12-24 00:55

    throw $e->getMessage();
    

    You try to throw a string

    As a sidenote: Exceptions are usually to define exceptional states of the application and not for error messages after validation. Its not an exception, when a user gives you invalid data

提交回复
热议问题