Groove Programming Tips & Tricks : Techniques to develop better tools in Groove
Updated: 1/21/2005; 10:19:45 AM.

 








Subscribe to "Groove Programming Tips & Tricks" in Radio UserLand.

Click to see the XML version of this web page.

 
 

Thursday, September 12, 2002

Return HRESULTs from script languages that implement COM interfaces

Groove's script host provides an object called GrooveErrorFunctions that you can use call the SetCurrentError method with an HRESULT value and string description.  The effect is that an exception is thrown to the caller with the value/description, so the caller should have exception handling code around the method call.

Example
function FindPerson
      (
      i_FirstName,
      i_LastName
      )
   {
   if (i_FirstName == "")
      {
      //   Return E_INVALIDARG (hex value = 0x80000003, integral value = -2147024809) 
      GrooveErrorFunctions.SetCurrentError(-2147024809, "First name required!");
      return;
      }

   if (i_LastName == "")
      {
      //   Return E_INVALIDARG (hex value = 0x80000003, integral value = -2147024809) 
      GrooveErrorFunctions.SetCurrentError(-2147024809, "Last name required!");
      return;
      }

   var Person = null;

   try
      {
      //   Some code here to find person
      }
   catch (e)
      {
      //   Return E_FAIL (hex value = 0x80004005, integral value = -2147467259) 
      GrooveErrorFunctions.SetCurrentError(-2147467259, "Unexpected error!");
      return;
      }

   return Person;
   }
8:50:12 AM    comment []

© Copyright 2005 Paresh Suthar.



Click here to visit the Radio UserLand website.
 


September 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Aug   Nov