Skip to content

Commit

Permalink
Merge pull request #88 from MindscapeHQ/mono-touch-exception
Browse files Browse the repository at this point in the history
Extract better stack trace from NSExceptions
  • Loading branch information
QuantumNightmare committed Oct 8, 2013
2 parents fa8e62f + c3002c5 commit 2cd01ed
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.11.0")]
[assembly: AssemblyFileVersion("1.0.11.0")]
[assembly: AssemblyVersion("1.0.12.0")]
[assembly: AssemblyFileVersion("1.0.12.0")]
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Mindscape.Raygun4Net</id>
<version>1.0.11</version>
<version>1.0.12</version>
<title />
<authors>Mindscape</authors>
<owners />
Expand Down
33 changes: 32 additions & 1 deletion Mindscape.Raygun4Net/Messages/RaygunErrorMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
using System.Reflection;
using System.Text;

#if IOS
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
#endif

namespace Mindscape.Raygun4Net.Messages
{
public class RaygunErrorMessage
Expand All @@ -27,9 +32,22 @@ public RaygunErrorMessage(Exception exception)
{
var exceptionType = exception.GetType();

#if IOS
MonoTouchException mex = exception as MonoTouchException;
if(mex != null && mex.NSException != null)
{
Message = string.Format("{0}: {1}", mex.NSException.Name, mex.NSException.Reason);
ClassName = mex.NSException.Name;
}
else{
#endif
Message = string.Format("{0}: {1}", exceptionType.Name, exception.Message);
StackTrace = BuildStackTrace(exception);
ClassName = exceptionType.FullName;
#if IOS
}
#endif

StackTrace = BuildStackTrace(exception);
Data = exception.Data;

if (exception.InnerException != null)
Expand Down Expand Up @@ -73,6 +91,19 @@ private RaygunErrorStackTraceLineMessage[] BuildStackTrace(Exception exception)
}
}
#else
#if IOS
MonoTouchException mex = exception as MonoTouchException;
if (mex != null && mex.NSException != null)
{
var ptr = Messaging.intptr_objc_msgSend (mex.NSException.Handle, Selector.GetHandle ("callStackSymbols"));
var arr = NSArray.StringArrayFromHandle (ptr);
foreach( var line in arr)
{
lines.Add(new RaygunErrorStackTraceLineMessage{ FileName = line});
}
return lines.ToArray();
}
#endif
var stackTrace = new StackTrace(exception, true);
var frames = stackTrace.GetFrames();

Expand Down
2 changes: 1 addition & 1 deletion XamarinComponent/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "rake/clean"
CLEAN.include "*.xam"
CLEAN.include "xpkg"

COMPONENT = "raygun4net-1.0.11.xam"
COMPONENT = "raygun4net-1.0.12.xam"

file "xpkg/xpkg.exe" do
sh "if exist xpkg del /Q xpkg & rd xpkg"
Expand Down

0 comments on commit 2cd01ed

Please sign in to comment.