2

In our Silk4J test environment, we use a naming convention in order to conveniently get access to windows. E.g. I can do

SapWindow pt61 = sap.performTransaction("PT61");

to perform the PT61 transaction in SAP and it'll return a window that has the identifier wndPT61 in a Silk4J Object Map.

Sometimes it happens that the window has not been mapped yet. In this case Silk4J causes a RuntimeException. Unfortunately, RuntimeException is used all over the place, i.e. it's not specific.

Is there a way to check the Object Maps for the existence of an identifer, so that I could detect the missing identifier and throw a more specific (custom) exception explaining what to do?

I'd like to do something like this:

if (!desktop.isValidIdentifier("wndPT61")) {
    throw new Exception("According to our naming convention ... etc.");
}

I have tried:

  • I have had a look at all methods of Desktop, but IMHO no such method exists. The exists() method already throws the RuntimeException.
  • I have had a look at all methods of Agent, but IMHO no such method exists.
  • I don't think such a method should be available at some other class, since desktop and agent are the highest level where a search can be done.
  • Of course I can catch the RuntimeException (that's what I do at the moment), but it's not very reliable (since such an exception could have other causes) and I don't want to rely on the exception message.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222

0 Answers0