- Home /
Poll which line of code app is stuck at?
Is it possible to find out which line of code is currently being parsed (or stumped at) during runtime on a Unity mobile app?
Is this on Unity remote or a build. I I believe you are trying to ask which line through the error may be a good way of saying it.
Error does not always show something - even when an app is frozen on Remote
Answer by CHPedersen · May 16, 2011 at 08:26 AM
You can surround your code with some try-catching in troublesome places, and then print the stacktrace to a file in the catch-clause:
try
{
// Error prone code
}
catch (System.Exception e)
{
System.IO.File.WriteAllText("YourErrorFile.txt", e.StackTrace);
}
This will shoot out the stacktrace to an error log you can later have a look at if your program crashes. The stacktrace should contain information on which method caused the crash and on which line. Keep in mind that the example is totally generic; in general you should never catch System.Exception because it'll swallow all exceptions and you won't know which precise one caused the crash. Instead, look up which exceptions your code might throw, then catch those. :P
Edit: It's probably a good idea to include some added information in a little header, such as DateTime.Now, so that you know which execution (and version of program) each error belongs to.
Your answer
Follow this Question
Related Questions
Crossplatform mobile development pipeline 0 Answers
Android Remote Receive Debug Output? 0 Answers
MonoDevelop Opening New Window 1 Answer
Is there a list of the Top 10 Unity Community? 0 Answers
Unity free on sony xperia s 2 Answers