Blob Blame History Raw
From fe3babab6413eeae50b5bdde98f2fc3dfbfc7aea Mon Sep 17 00:00:00 2001
From: Martin Quinson <martin.quinson@ens-rennes.fr>
Date: Thu, 9 May 2024 16:58:38 +0200
Subject: [PATCH] Remove one source of supurious error messages when writing
 files

Fixes https://github.com/mquinson/po4a/issues/494
---
 lib/Locale/Po4a/TransTractor.pm | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/lib/Locale/Po4a/TransTractor.pm b/lib/Locale/Po4a/TransTractor.pm
index 76b910a6..0d7a5edd 100644
--- a/lib/Locale/Po4a/TransTractor.pm
+++ b/lib/Locale/Po4a/TransTractor.pm
@@ -511,6 +511,11 @@ sub write {
     map { print $fh $_ } $self->docheader();
     eval {
         map { print $fh $_ } @{ $self->{TT}{doc_out} };
+
+        # we use the "eval {} or do {}" approach to deal with exceptions, cf https://perlmaven.com/fatal-errors-in-external-modules
+        # but we want it to fail only if there is an error. It seems to be some cases where "map" returns false even if there is no error.
+        # Thus this final 1 to evaluate to true in absence of error.
+        1;
     } or do {
         my $error = $@ || 'Unknown failure';
         chomp $error;
-- 
2.44.0