From 674a15a11f1c13bd8d903f2b980889e00955bde8 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 25 Oct 2012 17:28:09 +0100
Subject: [PATCH] ENH: regExp:improved error message

---
 src/OSspecific/POSIX/regExp.C | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/OSspecific/POSIX/regExp.C b/src/OSspecific/POSIX/regExp.C
index 3ce0d2c4471..2023f9ce598 100644
--- a/src/OSspecific/POSIX/regExp.C
+++ b/src/OSspecific/POSIX/regExp.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -80,12 +80,18 @@ void Foam::regExp::set(const char* pattern, const bool ignoreCase) const
             cflags |= REG_ICASE;
         }
 
-        if (regcomp(preg_, pattern, cflags) != 0)
+        int err = regcomp(preg_, pattern, cflags);
+
+        if (err != 0)
         {
+            char errbuf[200];
+            regerror(err, preg_, errbuf, sizeof(errbuf));
+
             FatalErrorIn
             (
                 "regExp::set(const char*)"
             )   << "Failed to compile regular expression '" << pattern << "'"
+                << nl << errbuf
                 << exit(FatalError);
         }
     }
-- 
GitLab