Index: OpenSceneGraph/trunk/src/osgPlugins/ply/vertexData.cpp
===================================================================
--- OpenSceneGraph/trunk/src/osgPlugins/ply/vertexData.cpp (revision 10012)
+++ OpenSceneGraph/trunk/src/osgPlugins/ply/vertexData.cpp (revision 10040)
@@ -158,10 +158,21 @@
     float   version;
     bool    result = false;
-    int        nComments;
-    char**    comments;
-    
-    PlyFile* file = ply_open_for_reading( const_cast< char* >( filename ), 
+    int     nComments;
+    char**  comments;
+    
+    PlyFile* file = NULL;
+
+    // Try to open ply file as for reading
+    try{
+            file  = ply_open_for_reading( const_cast< char* >( filename ), 
                                           &nPlyElems, &elemNames, 
                                           &fileType, &version );
+    }
+    // Catch the if any exception thrown
+    catch( exception& e )
+    {
+        MESHERROR << "Unable to read PLY file, an exception occured:  " 
+                    << e.what() << endl;
+    }
 
     if( !file )
@@ -173,4 +184,5 @@
 
     MESHASSERT( elemNames != 0 );
+    
 
     nComments = file->num_comments;
@@ -196,6 +208,14 @@
         int nProps;
         
-        PlyProperty** props = ply_get_element_description( file, elemNames[i], 
-                                                           &nElems, &nProps );
+        PlyProperty** props = NULL;
+        try{
+                props = ply_get_element_description( file, elemNames[i], 
+                                                     &nElems, &nProps );
+        }
+        catch( exception& e )
+        {
+            MESHERROR << "Unable to get PLY file description, an exception occured:  " 
+                        << e.what() << endl;
+        }
         MESHASSERT( props != 0 );
         
@@ -222,12 +242,23 @@
             if( ignoreColors )
                 MESHINFO << "Colors in PLY file ignored per request." << endl;
-            
-            // Read vertices and store in a std::vector array
-            readVertices( file, nElems, hasColors && !ignoreColors );
-            // Check whether all vertices are loaded or not
-            MESHASSERT( _vertices->size() == static_cast< size_t >( nElems ) );
-            // Check all color elements read or not
-            if( hasColors && !ignoreColors )
-                MESHASSERT( _colors->size() == static_cast< size_t >( nElems ) );
+         
+            try {   
+                // Read vertices and store in a std::vector array
+                readVertices( file, nElems, hasColors && !ignoreColors );
+                // Check whether all vertices are loaded or not
+                MESHASSERT( _vertices->size() == static_cast< size_t >( nElems ) );
+                // Check all color elements read or not
+                if( hasColors && !ignoreColors )
+                    MESHASSERT( _colors->size() == static_cast< size_t >( nElems ) );
+            }
+            catch( exception& e )
+            {
+                MESHERROR << "Unable to read vertex in PLY file, an exception occured:  " 
+                            << e.what() << endl;
+                // stop for loop by setting the loop variable to break condition
+                // this way resources still get released even on error cases
+                i = nPlyElems;
+                
+            }
         }
         // If the string is face means triangle info started
