From 9b9e673e4b925ad4adbd8464e988b951fa289e52 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 24 Sep 2020 17:11:47 -0700 Subject: [PATCH] ENH Replace E_USER_ERROR errors with exceptions --- code/Report.php | 10 ++++++---- code/ReportWrapper.php | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/Report.php b/code/Report.php index 5449dfeb..f1dad08f 100644 --- a/code/Report.php +++ b/code/Report.php @@ -147,11 +147,13 @@ class Report extends ViewableData */ public function sourceQuery($params) { - if ($this->hasMethod('sourceRecords')) { - return $this->sourceRecords($params, null, null)->dataQuery(); - } else { - user_error("Please override sourceQuery()/sourceRecords() and columns() or, if necessary, override getReportField()", E_USER_ERROR); + if (!$this->hasMethod('sourceRecords')) { + throw new \RuntimeException( + 'Please override sourceQuery()/sourceRecords() and columns() or, if necessary, override getReportField()' + ); } + + return $this->sourceRecords($params, null, null)->dataQuery(); } /** diff --git a/code/ReportWrapper.php b/code/ReportWrapper.php index 7ba44e76..e6fae9f2 100644 --- a/code/ReportWrapper.php +++ b/code/ReportWrapper.php @@ -75,7 +75,9 @@ abstract class ReportWrapper extends Report $this->afterQuery(); return $query; } else { - user_error("Please override sourceQuery()/sourceRecords() and columns() in your base report", E_USER_ERROR); + throw new \RuntimeException( + "Please override sourceQuery()/sourceRecords() and columns() in your base report" + ); } }