Search Unity

Question How to catch system exceptions with UVS?

Discussion in 'Visual Scripting' started by Marou1, Oct 30, 2022.

  1. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    Hello,

    I want to catch system exceptions to do something like this:

    Code (CSharp):
    1. try
    2. {
    3. SaveData(data);
    4. }
    5. catch(System.IO.IOException)
    6. {
    7.     DisplayMessage("The file is open elsewhere or there is not enough storage space");
    8. }
    9. catch(System.Security.SecurityException)
    10. {
    11.     DisplayMessage("Could not save as you do not have the required permissions");
    12. }
    ...

    Basically I need to catch these 4 exceptions:
    System.IO.IOException
    System.Security.SecurityException
    System.FormatException
    System.ArgumentException

    I added System Exception in the nodes in Project Settings, but I cannot find these exceptions. Also, I am not sure how to use the Try&Catch node.

    Thanks