Index: Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs =================================================================== diff -u -r8e91f29f35b5f93ea1d9dfc7dcd79edfdd1b4e53 -rc909efdf6275b926fd146b4abad96682a9ff0f0f --- Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (.../PolylineShapeFileReader.cs) (revision 8e91f29f35b5f93ea1d9dfc7dcd79edfdd1b4e53) +++ Core/Components/src/Core.Components.Gis.IO/Readers/PolylineShapeFileReader.cs (.../PolylineShapeFileReader.cs) (revision c909efdf6275b926fd146b4abad96682a9ff0f0f) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.IO.Exceptions; @@ -59,12 +60,17 @@ { ShapeFile = new LineShapefile(shapeFilePath); } - catch (ArgumentException e) + catch (ArgumentException exception) { string message = new FileReaderErrorMessageBuilder(shapeFilePath) .Build(GisIOResources.LineShapeFileReader_File_contains_geometries_not_line); - throw new CriticalFileReadException(message, e); + throw new CriticalFileReadException(message, exception); } + catch (IOException exception) + { + var message = new FileReaderErrorMessageBuilder(shapeFilePath).Build(CoreCommonUtilsResources.Error_General_IO_ErrorMessage); + throw new CriticalFileReadException(message, exception); + } } /// Index: Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs =================================================================== diff -u -r8e91f29f35b5f93ea1d9dfc7dcd79edfdd1b4e53 -rc909efdf6275b926fd146b4abad96682a9ff0f0f --- Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs (.../PolylineShapeFileReaderTest.cs) (revision 8e91f29f35b5f93ea1d9dfc7dcd79edfdd1b4e53) +++ Core/Components/test/Core.Components.Gis.IO.Test/Readers/PolylineShapeFileReaderTest.cs (.../PolylineShapeFileReaderTest.cs) (revision c909efdf6275b926fd146b4abad96682a9ff0f0f) @@ -20,6 +20,7 @@ // All rights reserved. using System.Collections.Generic; +using System.IO; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.IO.Exceptions; @@ -72,6 +73,26 @@ } [Test] + public void ParameteredConstructor_ShapeFileIsInUse_ThrowsCriticalFileReadException() + { + // Setup + string testFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "traject_10-1.shp"); + + using (File.Open(testFilePath, FileMode.Open, FileAccess.ReadWrite)) + { + // Call + TestDelegate call = () => new PolylineShapeFileReader(testFilePath); + + // Assert + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Er is een onverwachte fout opgetreden tijdens het inlezen van het bestand.", + testFilePath); + CriticalFileReadException exception = Assert.Throws(call); + Assert.AreEqual(expectedMessage, exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] public void GetNumberOfLines_EmptyLineShapeFile_ReturnZero() { // Setup