Search Unity

Error catching -- supported?

Discussion in 'Scripting' started by StarManta, Oct 30, 2006.

  1. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Is there any documentation for Unity's exception handling? My try-catch code does not seem to be working.

    Code (csharp):
    1.     try {
    2.         PathTo = PFHelper(transform.position, pos, PathFindIterations);
    3.     }
    4.     catch (err) {
    5.         print(err.message);
    6.         PathTo = new Array(transform.position);
    7.     }
    This code gives me the error:

    Assets/Scripts-control/EnemyMovement.js(181) error BCE0120: 'System.Exception.message' is unaccessible due to its protection level. (Filename: Assets/Scripts-control/EnemyMovement.js Line: 181)
     
  2. Talzor

    Talzor

    Joined:
    May 30, 2006
    Posts:
    197
    print(err.message) has to be print(err.Message). You can see a full overview of the exception class on MSDN
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Thanks.

    Is it just me, or is that nonstandard? Usually members are lowercase...
     
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    .NET naming convention starts names with upper case for both methods and properties. This is different from Java's naming convention.