Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
public class Activity
    implements org.osid.learning.Activity {
    
    private org.osid.id.Id objectiveId;
    private org.osid.learning.ObjectiveLookupSession objectives;
    ...
    @OSID
    public org.osid.id.Id getObjectiveId() {
        return (this.objectiveId);
    }
    
    @OSID 
    public org.osid.learning.Objective getObjective()
        throws org.osid.OperationFailedException {
        
        try {
            return (this.objectives.getObjective(getObjectiveId()));
        } catch (org.osid.DoesNotExistException dne) {
            throw new org.osid.OperationFailedException("for some strange reason, there is no Objective for this Activity. Maybe we're talking to the wrong provider?", dne)
        } catch (org.osid.PermissionDeniedException pde) {
            throw new org.osid.OperationFailedException("for some inexplicable reason you cannot see the Objective for your Activity. Authorization setup is fakakta. ", pde);
        } 
    }
    ...

In the above example, the getObjective() call is implemented using an ObjectiveLookupSession. ObjectiveLookupSession.getObjective defines DoesNotExistException and PermissionDeniedException not present in Activity.getObjective() (ignoring the unchecked exceptions which imply a programming/integration problem which should not be handled here).

The Activity says that it has an Objective. Therefore, the Objective must exist. To say that Activity.getObjective() should also throw a DoesNotExistException ignores this tenet. If for whatever reason, the provider cannot come up with one should be considered an error due to the result of a breakage in connectivity, data integrity, authorization, configuration, or something which should not occur in normal operations. Semantics like this is what generally causes exception misalignments across method calls.

Do we worry only when exceptions don’t line up?

Method Factoring

Passing The Buck

...