From: Ankit Jain Date: Fri, 11 Mar 2011 13:05:19 +0000 (+0530) Subject: [xbuild] Handle unknown exceptions. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mono.git;a=commitdiff_plain;h=03f08179920933a57d3588946acada870a42e5d5 [xbuild] Handle unknown exceptions. Re-throw any unknown exceptions. * Project.cs: Log the exception, doing it here also, so that direct project.Build(..) call failures also get logged. * Engine.cs: Log the unknown exception only if the build is running. This allows for the case when Project.Build caught it and ended the build. --- diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs index 47b5ffddffd..7d5db3f64b3 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs @@ -239,9 +239,11 @@ namespace Microsoft.Build.BuildEngine { this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, ie.ToString ())); return false; } catch (Exception e) { - this.LogErrorWithFilename (projectFile, e.Message); - this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, e.ToString ())); - return false; + if (buildStarted) { + this.LogErrorWithFilename (projectFile, e.Message); + this.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", projectFile, e.ToString ())); + } + throw; } finally { EndEngineBuild (result); } diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs index d2f46612121..6e7971deb7a 100644 --- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs +++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs @@ -297,6 +297,13 @@ namespace Microsoft.Build.BuildEngine { Directory.SetCurrentDirectory (Path.GetDirectoryName (fullFileName)); building = true; result = BuildInternal (targetNames, targetOutputs, buildFlags); + } catch (InvalidProjectFileException ie) { + ParentEngine.LogErrorWithFilename (fullFileName, ie.Message); + ParentEngine.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", fullFileName, ie.ToString ())); + } catch (Exception e) { + ParentEngine.LogErrorWithFilename (fullFileName, e.Message); + ParentEngine.LogMessage (MessageImportance.Low, String.Format ("{0}: {1}", fullFileName, e.ToString ())); + throw; } finally { ParentEngine.EndProjectBuild (this, result); current_settings = BuildSettings.None;