From f8ce479997bb9e0fb9ec4ada30fca01f850d60f1 Mon Sep 17 00:00:00 2001 From: Siad Ardroumli Date: Sat, 14 Sep 2024 16:52:25 +0200 Subject: [PATCH] [ReplaceRegexpTask] Added fail on error support --- src/Phing/Task/System/ReplaceRegexpTask.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Phing/Task/System/ReplaceRegexpTask.php b/src/Phing/Task/System/ReplaceRegexpTask.php index 38726f4540..0edcf7bbd7 100644 --- a/src/Phing/Task/System/ReplaceRegexpTask.php +++ b/src/Phing/Task/System/ReplaceRegexpTask.php @@ -65,6 +65,15 @@ class ReplaceRegexpTask extends Task */ private $regexp; + private $failonerror = false; + + /** + * If false, note errors but continue. + */ + public void setFailOnError($failonerror) { + $this->failonerror = $failonerror; + } + /** * File to apply regexp on. */ @@ -201,6 +210,9 @@ public function main() $in->close(); } $this->log('Error reading file: ' . $e->getMessage(), Project::MSG_WARN); + if ($this->failonerror) { + throw new BuildException("Error reading file: '" . $file->getAbsolutePath() . "'", $e); + } } try { @@ -214,6 +226,9 @@ public function main() $out->close(); } $this->log('Error writing file back: ' . $e->getMessage(), Project::MSG_WARN); + if ($this->failonerror) { + throw new BuildException("Error writing file back: '" . $file->getAbsolutePath() . "'", $e); + } } } }