← Back to team overview

sikuli-driver team mailing list archive

[Bug 1382653] Re: [1.1.4] functions like click should should throw exception with wrong target type

 

** Changed in: sikuli
       Status: Fix Committed => In Progress

** Changed in: sikuli
   Importance: High => Medium

** Changed in: sikuli
    Milestone: 1.1.4 => 2.1.0

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1382653

Title:
  [1.1.4] functions like click should should throw exception with wrong
  target type

Status in Sikuli:
  In Progress

Bug description:
  Probably i'm stupid, but twice now I've tried to call

  region.click(rect)

  where rect is java.awt.Rectangle, which is not a supported target
  type.

  The function simply does nothing and returns 0 (which i ignore).

  Don't you suppose it would be better if it throws FindFailed? or else
  UnsupportedTargetType?

    private <PSIMRL> Location getLocationFromTarget(PSIMRL target) throws FindFailed {
      if (target instanceof Pattern || target instanceof String || target instanceof Image) {
        Match m = find(target);
        if (m != null) {
          if (isOtherScreen()) {
            return m.getTarget().setOtherScreen(scr);
          } else {
            return m.getTarget();
          }
        }
        return null;        <======== SHOULD BE A THROW FINDFAILED
      }
      if (target instanceof Match) {
        return ((Match) target).getTarget();
      }
      if (target instanceof Region) {
        return ((Region) target).getCenter();
      }
      if (target instanceof Location) {
        return new Location((Location) target);
      }
      return null;        <======== SHOULD BE A THROW BAD TARGET TYPE
    }

  
  I can't see any situation where return null is helpful. I think a throw is better.

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1382653/+subscriptions


References