aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-17 03:17:42 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-17 03:17:42 +0100
commit81355c4df1b311dca6150c48a477ee367c78e0bf (patch)
tree2b3e75af46b9b8be2aac853ff4afd0f8739cbbb8 /src
parent582948e8d254d9553b96d31102566fb59e0798de (diff)
InstantiatorException with file name
Diffstat (limited to 'src')
-rw-r--r--src/Instantiator.cs39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/Instantiator.cs b/src/Instantiator.cs
index c75c8b9f..a97f19d2 100644
--- a/src/Instantiator.cs
+++ b/src/Instantiator.cs
@@ -38,6 +38,13 @@ using Crow.IML;
namespace Crow.IML
{
+ public class InstantiatorException : Exception {
+ public string Path;
+ public InstantiatorException (string path, Exception innerException)
+ : base ("ITor exception in " + path, innerException){
+ Path = path;
+ }
+ }
public delegate object InstanciatorInvoker(Interface iface);
/// <summary>
@@ -70,27 +77,33 @@ namespace Crow.IML
/// <summary>
/// Initializes a new instance of the Instantiator class.
/// </summary>
- public Instantiator (string path) : this (Interface.GetStreamFromPath(path)) {
- sourcePath = path;
+ public Instantiator (string path) : this (Interface.GetStreamFromPath(path), path) {
+
}
/// <summary>
/// Initializes a new instance of the Instantiator class.
/// </summary>
- public Instantiator (Stream stream)
+ public Instantiator (Stream stream, string srcPath = null)
{
-#if DEBUG_LOAD
+ sourcePath = srcPath;
+ #if DEBUG_LOAD
Stopwatch loadingTime = new Stopwatch ();
loadingTime.Start ();
-#endif
- using (XmlReader itr = XmlReader.Create (stream)) {
- parseIML (itr);
- }
- stream.Dispose ();
-#if DEBUG_LOAD
- loadingTime.Stop ();
- Debug.WriteLine ("IML Instantiator creation '{2}' : {0} ticks, {1} ms",
+ #endif
+ try {
+ using (XmlReader itr = XmlReader.Create (stream)) {
+ parseIML (itr);
+ }
+ stream.Dispose ();
+ } catch (Exception ex) {
+ throw new InstantiatorException(sourcePath, ex);
+ } finally {
+ #if DEBUG_LOAD
+ loadingTime.Stop ();
+ Debug.WriteLine ("IML Instantiator creation '{2}' : {0} ticks, {1} ms",
loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, imlPath);
-#endif
+ #endif
+ }
}
/// <summary>
/// Initializes a new instance of the Instantiator class with an already openned xml reader