Search Unity

App keeps running after error, how to make it crash?

Discussion in 'Editor & General Support' started by Dingola, Nov 12, 2018.

  1. Dingola

    Dingola

    Joined:
    Jul 11, 2015
    Posts:
    6
    Hey guys!

    I haven't really found any info about this.

    Is there any way to make my app crash & quit itself when encountering any kind of errors? Right now my app just keeps running after having the error, resulting in glitchy play.

    Thanks for reading.
     
  2. DuckType

    DuckType

    Joined:
    Mar 21, 2015
    Posts:
    18
    I think it's kind of the point that Unity keeps running in this case, otherwise it would be much harder to debug your project.

    If you want the game to shut down you can catch your exception and call https://docs.unity3d.com/ScriptReference/Application.Quit.html

    You can also check if the game is running inside the editor or as a standalone using https://docs.unity3d.com/ScriptReference/Application-isEditor.html
    This way you could shut it down only when someone is playing it, not when you're working on it and want to see those errors to debug

    There's also some good answers here: https://answers.unity.com/questions/130402/stop-game-on-exception.html
     
  3. Dingola

    Dingola

    Joined:
    Jul 11, 2015
    Posts:
    6
    Thank you for the reply!

    Yes in the editor this feature is a good thing to have, however when the game is published, it is not healthy to keep a software up which has become unpredictable after an error.

    I was playing with the idea of catching our exception and call Application.Quit, but then I would have to put the catch code literally almost everywhere? Is there a simpler way to implement this?

    Thanks for reading.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    It is not healthy for your game's reviews if it routinely crashed to desktop for even the most innocuous error. A minor glitch gets a mention, repeated crashing gets a 1 star review and all caps warnings to other potential customers not to buy, which won't be taken down when you fix the issue.
     
  5. DuckType

    DuckType

    Joined:
    Mar 21, 2015
    Posts:
    18
    Yes you would have to put catch code almost everywhere. It's not really an elegant solution but as Joe-Censored said it's not desirable in most cases to have a game crash for every small error.

    It might be better if, instead of crashing, the game showed a warning or reset the level or something like that