Use custom exception for replay creation failures

This commit is contained in:
baldurk
2016-08-04 14:14:29 +02:00
parent 42f57990d9
commit 8a5d300e78
6 changed files with 34 additions and 22 deletions
+3 -3
View File
@@ -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;
}
+1 -3
View File
@@ -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);
+20 -9
View File
@@ -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);
+2 -2
View File
@@ -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
{
+6 -3
View File
@@ -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)
{
}
});
+2 -2
View File
@@ -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)
{
}
}