From 80c23d4f69a7463e75d7d1502d603d9b01891481 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Thu, 29 Sep 2016 16:19:05 +0200
Subject: [PATCH] handle the case when a file can't be opened

---
 VECTO/GUI/VectoJobForm.vb | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb
index c36056dc24..e1adc35097 100644
--- a/VECTO/GUI/VectoJobForm.vb
+++ b/VECTO/GUI/VectoJobForm.vb
@@ -14,6 +14,7 @@ Imports System.Collections.Generic
 Imports System.Drawing.Imaging
 Imports System.IO
 Imports System.Linq
+Imports System.Runtime.CompilerServices
 Imports System.Text.RegularExpressions
 Imports System.Windows.Forms.DataVisualization.Charting
 Imports TUGraz.VECTO.Input_Files
@@ -370,9 +371,17 @@ Public Class VectoJobForm
 		VectoNew()
 
 		'Read GEN
-		Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), 
-																IEngineeringInputDataProvider)
-		Dim vectoJob As IEngineeringJobInputData = inputData.JobInputData()
+		Dim vectoJob As IEngineeringJobInputData = Nothing
+		Dim inputData As IEngineeringInputDataProvider = Nothing
+		Try
+			inputData = TryCast(JSONInputDataFactory.ReadComponentData(file), 
+								IEngineeringInputDataProvider)
+			vectoJob = inputData.JobInputData()
+		Catch ex As Exception
+			MsgBox("Failed to read Job-File" + Environment.NewLine + ex.Message)
+			Return
+		End Try
+
 
 		If Cfg.DeclMode <> vectoJob.SavedInDeclarationMode Then
 			Select Case WrongMode()
-- 
GitLab