Error handling in navision

How to handle automation control error in Navision ? same like Try catch in .net

I have resolved the Automation error handling problem.

Let’s I have explain

Step 1
Create two code unit

Codeunit A
Codeunit B

Step 2

In Codeunit - B

Declare the global variable
Add1
City
Region
Postcode
Country

Create Two function in codeunit B

  1. SetParameter(_Add1,_City,_Region,_PostCode,_Country)
    {
    Add1 := _Add1;
    City := _City;
    Region := _Region;
    Postcode :=_Postcode;
    Country := _Country;
    }

2)IsAddressFind()
{
//Map Point Automation Variable
MapPointFindResult := MapPointMap.FindAddressResults(Add1,City,‘’,Region,PostCode,Country);
}

OnRun() - Trigger
{
IsAddressFind()
}

Step 3
In Codeunit - A

Decalre Bool varible Isyes
Declare B as Codeunit B

Initi Map

Create Function
GetLocation(_Add1,_City,_Region,_PostCode,_Country)
{
CLEARLASTERROR();
// Pass the parameter in codeunit b becuase we can not pass the parameter in run so i have create setparameter function and passs it
B.SetParameter(_Add1,_City,_Region,_PostCode,_Country)
IsYes := B.Run();

IF IsYes = FALSE THEN BEGIN
message(GETLASTERRORTEXT);
CLEARLASTERROR();
end else begin
message(‘Sucessfully executed’);
END;
}

Close Map

Please note - I am not write 100% accurate code , I have just try to explain how to handle error

I hope this solution help to our community for handling error in navision