diff --git a/renderdocui/Code/RenderManager.cs b/renderdocui/Code/RenderManager.cs index f55b5f76b..3a32c6a8f 100644 --- a/renderdocui/Code/RenderManager.cs +++ b/renderdocui/Code/RenderManager.cs @@ -150,7 +150,7 @@ namespace renderdocui.Code { m_Remote = StaticExports.CreateRemoteServer(hostname, 0); } - catch (ApplicationException ex) + catch (ReplayCreateException ex) { InitException = ex; } @@ -162,7 +162,7 @@ namespace renderdocui.Code m_Remote.ShutdownConnection(); } - public ApplicationException InitException = null; + public ReplayCreateException InitException = null; public void CloseThreadSync() { @@ -295,7 +295,7 @@ namespace renderdocui.Code DestroyReplayRenderer(renderer); } } - catch (ApplicationException ex) + catch (ReplayCreateException ex) { InitException = ex; } diff --git a/renderdocui/Interop/ReplayRenderer.cs b/renderdocui/Interop/ReplayRenderer.cs index fde2b5730..8c5154123 100644 --- a/renderdocui/Interop/ReplayRenderer.cs +++ b/renderdocui/Interop/ReplayRenderer.cs @@ -977,9 +977,7 @@ namespace renderdoc if (rendPtr == IntPtr.Zero || ret != ReplayCreateStatus.Success) { - var e = new System.ApplicationException("Failed to set up local proxy replay with remote connection"); - e.Data.Add("status", ret); - throw e; + throw new ReplayCreateException(ret, "Failed to set up local proxy replay with remote connection"); } return new ReplayRenderer(rendPtr); diff --git a/renderdocui/Interop/StaticExports.cs b/renderdocui/Interop/StaticExports.cs index 878c5f250..dd91c2777 100644 --- a/renderdocui/Interop/StaticExports.cs +++ b/renderdocui/Interop/StaticExports.cs @@ -29,6 +29,23 @@ using System.Text; namespace renderdoc { + public class ReplayCreateException : Exception + { + public ReplayCreateException(ReplayCreateStatus status) + : base(String.Format("Replay creation failure: {0}", status.Str())) + { + Status = status; + } + + public ReplayCreateException(ReplayCreateStatus status, string msg) + : base(msg) + { + Status = status; + } + + public ReplayCreateStatus Status; + } + class StaticExports { [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] @@ -111,9 +128,7 @@ namespace renderdoc if (rendPtr == IntPtr.Zero || ret != ReplayCreateStatus.Success) { - var e = new System.ApplicationException("Failed to load log for local replay"); - e.Data.Add("status", ret); - throw e; + throw new ReplayCreateException(ret, "Failed to load log for local replay"); } return new ReplayRenderer(rendPtr); @@ -170,9 +185,7 @@ namespace renderdoc if (rendPtr == IntPtr.Zero) { - var e = new System.ApplicationException("Failed to open remote access connection"); - e.Data.Add("status", ReplayCreateStatus.UnknownError); - throw e; + throw new ReplayCreateException(ReplayCreateStatus.NetworkIOFailed, "Failed to open remote access connection"); } return new TargetControl(rendPtr); @@ -214,9 +227,7 @@ namespace renderdoc if (rendPtr == IntPtr.Zero || ret != ReplayCreateStatus.Success) { - var e = new System.ApplicationException("Failed to connect to remote replay host"); - e.Data.Add("status", ret); - throw e; + throw new ReplayCreateException(ret, "Failed to connect to remote replay host"); } return new RemoteServer(rendPtr); diff --git a/renderdocui/Windows/Dialogs/LiveCapture.cs b/renderdocui/Windows/Dialogs/LiveCapture.cs index 486008cd3..14c5aaa3a 100644 --- a/renderdocui/Windows/Dialogs/LiveCapture.cs +++ b/renderdocui/Windows/Dialogs/LiveCapture.cs @@ -169,7 +169,7 @@ namespace renderdocui.Windows } else { - throw new ApplicationException(); + throw new ReplayCreateException(ReplayCreateStatus.NetworkIOFailed); } while (m_Connection.Connected) @@ -264,7 +264,7 @@ namespace renderdocui.Windows ConnectionClosed(); }); } - catch (ApplicationException) + catch (ReplayCreateException) { this.BeginInvoke((MethodInvoker)delegate { diff --git a/renderdocui/Windows/Dialogs/RemoteManager.cs b/renderdocui/Windows/Dialogs/RemoteManager.cs index fad568c4e..23374f040 100644 --- a/renderdocui/Windows/Dialogs/RemoteManager.cs +++ b/renderdocui/Windows/Dialogs/RemoteManager.cs @@ -170,9 +170,12 @@ namespace renderdocui.Windows.Dialogs SetRemoteServerLive(node, true); server.ShutdownConnection(); } - catch (ApplicationException) + catch (ReplayCreateException ex) { - SetRemoteServerLive(node, false); + if(ex.Status == ReplayCreateStatus.NetworkRemoteBusy) + SetRemoteServerLive(node, true); + else + SetRemoteServerLive(node, false); } StaticExports.EnumerateRemoteTargets(hostname, (UInt32 i) => { @@ -204,7 +207,7 @@ namespace renderdocui.Windows.Dialogs conn.Shutdown(); } - catch (ApplicationException) + catch (ReplayCreateException) { } }); diff --git a/renderdocui/Windows/MainWindow.cs b/renderdocui/Windows/MainWindow.cs index e7530cc86..918835daa 100644 --- a/renderdocui/Windows/MainWindow.cs +++ b/renderdocui/Windows/MainWindow.cs @@ -959,7 +959,7 @@ namespace renderdocui.Windows // if we got this far without an exception, the server is running host.ServerRunning = true; } - catch (ApplicationException) + catch (ReplayCreateException) { } @@ -978,7 +978,7 @@ namespace renderdocui.Windows // if we got this far without an exception, the server is running host.ServerRunning = true; } - catch (ApplicationException) + catch (ReplayCreateException) { } }