From 86ce9a510eddf90a88904e236a3e57b796be55fc Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Mon, 25 Mar 2013 16:21:54 +0000
Subject: [PATCH] ENH: PtrList,UPtrList: improved debug message

---
 src/OpenFOAM/containers/Lists/PtrList/PtrListI.H   | 10 +++++++---
 src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H | 10 +++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H
index 3f29e9238f3..979e862d4a7 100644
--- a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H
+++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H
@@ -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-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -132,7 +132,9 @@ inline const T& Foam::PtrList<T>::operator[](const label i) const
     if (!ptrs_[i])
     {
         FatalErrorIn("PtrList::operator[] const")
-            << "hanging pointer, cannot dereference"
+            << "hanging pointer at index " << i
+            << " (size " << size()
+            << "), cannot dereference"
             << abort(FatalError);
     }
 
@@ -146,7 +148,9 @@ inline T& Foam::PtrList<T>::operator[](const label i)
     if (!ptrs_[i])
     {
         FatalErrorIn("PtrList::operator[]")
-            << "hanging pointer, cannot dereference"
+            << "hanging pointer at index " << i
+            << " (size " << size()
+            << "), cannot dereference"
             << abort(FatalError);
     }
 
diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H
index dceeb1f2796..38bb4309314 100644
--- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H
+++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H
@@ -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-2013 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -107,7 +107,9 @@ inline const T& Foam::UPtrList<T>::operator[](const label i) const
     if (!ptrs_[i])
     {
         FatalErrorIn("UPtrList::operator[] const")
-            << "hanging pointer, cannot dereference"
+            << "hanging pointer at index " << i
+            << " (size " << size()
+            << "), cannot dereference"
             << abort(FatalError);
     }
 
@@ -121,7 +123,9 @@ inline T& Foam::UPtrList<T>::operator[](const label i)
     if (!ptrs_[i])
     {
         FatalErrorIn("UPtrList::operator[]")
-            << "hanging pointer, cannot dereference"
+            << "hanging pointer at index " << i
+            << " (size " << size()
+            << "), cannot dereference"
             << abort(FatalError);
     }
 
-- 
GitLab