ProjectException#

Thrown when a call doesn't fit the current state of a Project: the project has no solved baseline, a baseline token is out of date, or an earlier apply rejected operations. The code field says which.

Declaration#

package org.dhtmlx.plen;

public class ProjectException extends PlenException

Unchecked: it extends PlenException, a RuntimeException, and no method declares it in throws. catch (PlenException e) also catches it.

Constructors#

ProjectException(ProjectError)#

public ProjectException(ProjectError code)

Creates the exception with the given code. The message is the code's kebab-case spelling.

Parameters

Name Type Description
code ProjectError The error code

Fields#

code#

public ProjectError code

The error code. Branch on it to pick the recovery.

Methods#

withCode#

public ProjectException withCode(ProjectError value)

Sets code and returns this exception. The message keeps the spelling of the code passed to the constructor.

getMessage#

public String getMessage()

Inherited from Throwable. Returns the kebab-case code: "no-baseline", "stale-baseline" or "needs-resync".

ProjectError#

The code of a ProjectException.

package org.dhtmlx.plen;

public enum ProjectError {
    NO_BASELINE,
    STALE_BASELINE,
    NEEDS_RESYNC
}
Value Message When it occurs Thrown by
NO_BASELINE no-baseline The project has no solved baseline: it was never solved, or it has unsolved edits after apply preview, loadProfile, evaluate, suggestAssignments, roster
STALE_BASELINE stale-baseline A baselineId in the options or in SchedulingChanges doesn't name the current baseline. A null baselineId is never checked preview, apply, loadProfile, evaluate, suggestAssignments
NEEDS_RESYNC needs-resync An earlier apply rejected an operation, and no full solve(data, …) has followed. Only a solve with non-null data clears it solve with null data, apply, level

SkillLayer.slots reports NO_BASELINE as a MatchException.Project that wraps a ProjectException.

For how to recover from each code, see Error handling.

Example#

import org.dhtmlx.plen.*;

public class NoBaseline {
    public static void main(String[] args) throws Exception {
        var project = new Project();
        try {
            project.preview(new SchedulingChanges(), new PreviewOptions());
        } catch (ProjectException e) {
            if (e.code == ProjectError.NO_BASELINE) {
                System.out.println(e.getMessage()); // no-baseline
            }
        }
    }
}