skip to main content
Gantt > Programmer's documentation > Developing with the JViews Gantt SDK > Critical path analysis > Handling errors
 
Handling errors
Critical path analysis cannot be performed if cyclical dependencies exist between the activities and constraints in your Gantt data model. The IlvCriticalPathCalculator.computeSchedule() method will throw an IlvConstraintCycleException if such a cyclical dependency is detected. By contrast, the IlvGanttModelScheduler class does not directly throw exceptions when a cyclical dependency is found. Instead, it notifies its currently registered error handler of the problem. This allows you to easily implement a custom error handler that can inform the user in a manner that is appropriate to your application's user interface. The default error handler simply logs the exception. The following code shows a custom error handler that displays detected cycles in a Swing JLabel object:
JLabel errorText = ...
IlvGanttModel model = ...
IlvGanttModelScheduler scheduler = new IlvGanttModelScheduler(ganttModel);
scheduler.setErrorHandler(new IlvGanttModelScheduler.ErrorHandler() {
  public void error(IlvConstraintCycleException ex,
                    IlvGanttModel ganttModel) {
    errorText.setText("Cycle at " + ex.getActivity().getName());
  }
});

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.