4 Replies Latest reply on Mar 21, 2016 9:09 AM by Rhys Kirk

    How to get PI Error Messages

    Argel

      Hi,

       

      Is it possible to get the actual error messages from PI?

       

      For example I have this code:

      PIServer piServer = new PIServers()["WRONG-PI-SERVER-NAME"];
      piServer.Connect();
      

       

      On piServer.Connect, if it can't find the specified pi server, it will throw this exception:

       

      My question is, is there a way to get the actual error that PI will throw in this example of an instance. Example, P Server not found, something like that.

       

      Thanks!

        • Re: How to get PI Error Messages
          Nocodes79

          Hi Argel,

           

          just put it in a try catch.

           

          On the other hand, for this particular case, there is no specific error I think. If piServer is null, the server is not registered in PI-SDK.

           

                      string piServerName = "WRONG-PI-SERVER-NAME";
                      PIServer piServer = (new PIServers())[piServerName];
          
          
                      try
                      {
                          piServer.Connect();
          
          
                      }
                      catch ( NullReferenceException )
                      {
                          //null piServer, check the PI SDK Utility
                          Console.WriteLine("Unregistered PI, please check if {0} is registered in PI SDK Utility", piServerName);
                      }
                      catch (Exception otherExc)
                      {
                          //generic exception
                          Console.WriteLine("Error: {0}", otherExc.Message);
                      }
          
          • Re: How to get PI Error Messages
            Nocodes79

            As long as I know, no