You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ErrorTrait.php 585B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace crmeb\traits;
  3. /**
  4. *
  5. * Class BaseError
  6. */
  7. trait ErrorTrait
  8. {
  9. /**
  10. * 错误信息
  11. * @var string
  12. */
  13. protected $error;
  14. /**
  15. * 设置错误信息
  16. * @param string|null $error
  17. * @return bool
  18. */
  19. protected function setError(?string $error = null)
  20. {
  21. $this->error = $error ?: '未知错误';
  22. return false;
  23. }
  24. /**
  25. * 获取错误信息
  26. * @return string
  27. */
  28. public function getError()
  29. {
  30. $error = $this->error;
  31. $this->error = null;
  32. return $error;
  33. }
  34. }