PlenException#

Abstract base of every exception the engine throws: InputException for invalid input, and ProjectException for a call that doesn't fit the project's state. It's unchecked, so no method declares it in throws. Catch it to handle any engine failure in one place.

Declaration#

package org.dhtmlx.plen;

public abstract class PlenException extends RuntimeException

Constructors#

PlenException#

public PlenException(String message)

Sets the exception message. Called by the subclass constructors; application code doesn't create engine exceptions.

Parameters

Name Type Description
message String Text returned by getMessage()

Methods#

getMessage#

public String getMessage()

Inherited from Throwable. The text depends on the subclass: the validation message for InputException, the kebab-case error code ("no-baseline", "stale-baseline", "needs-resync") for ProjectException.

Returns the message passed to the constructor.

Subclasses#

Subclass When it occurs
InputException The input is invalid. kind and path say what failed and where.
ProjectException The call doesn't fit the project's state. code names the state.

Each operation page lists which of the two it throws. MatchException, thrown by SkillLayer.slots, doesn't extend PlenException; its toPlenException() returns the matching InputException or ProjectException. JDK exceptions (NullPointerException for a null argument, and others) don't extend it either. Conflicts, cycles, failure to converge and operations rejected by Project#apply come back in results, not as exceptions. See Error handling.

Example#

import java.util.List;
import org.dhtmlx.plen.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Moment start = Moment.fromYmdHm(2026, 1, 5, 8, 0);

        // Two tasks with the same id fail validation.
        ProjectData data = new ProjectData().withTasks(List.of(
            new TaskData(Id.num(1)).withStartDate(start).withDuration(2.0),
            new TaskData(Id.num(1)).withStartDate(start).withDuration(3.0)));

        Project project = new Project();

        try {
            project.solve(data, new SolveOptions());
        } catch (PlenException e) {
            switch (e) {
                case InputException input ->
                    System.out.println("Invalid input at " + input.path + ": " + input.getMessage());
                case ProjectException state ->
                    System.out.println("Project state: " + state.code);
                default ->
                    System.out.println(e.getMessage());
            }
        }
    }
}