Skip to content

Errors and validation ​

Every public function and component validates its input at the boundary. Invalid numbers and geometry throw a RangeError; bad references, invalid or duplicate IDs and cycles throw an Error. Scheduling failures such as cycles and infeasible plans are returned as results instead of thrown. A component reports invalid props through its validation-error event, renders its empty state and rethrows the error.

Branch on the error class and on the code and id fields of diagnostics, never on message text: the texts below help people read logs, but they can change in a minor release.

ts
import { scheduleTasks } from '@eightkk/vue-weave/core'

try {
  const result = scheduleTasks(input)
  if (!result.ok) showDiagnostics(result) // cycles and infeasible plans are results
} catch (error) {
  if (error instanceof RangeError) reportBadNumber(error) // non-finite times, inverted ranges
  else throw error // bad references, duplicate IDs
}

See also Planning diagnostics and schedule traces for the diagnostics of a plan, and the validateEdit, validateConnection and validateCellEdit props of the components for rejecting user edits.

Validation and errors ​

The planning, timeline and data functions of @eightkk/vue-weave/core (scheduling, leveling and resource load, status-date and actuals rescheduling, plan comparison, placement, resource timelines, timeline data and row trees, renderTimelineSvg, snapshots, windowed data and the MS Project, iCalendar and CSV interchange), its graph functions (indexGraph and everything that validates a graph through it: every layout, the algorithms and analysis, editing, port rules and renderGraphSvg; group collapse, swimlanes, traversal, layout requests and the view bindings) and the prop checks of GanttChart and NetworkGraph share one ID rule: an ID is a non-empty string, and IDs are unique within their collection. Any other value (a number such as 0 or 5, '', null, undefined, an object) is invalid. Each failure kind currently has one message format, thrown as an Error. The texts help people read logs; they are not part of the compatibility promise, so code should check the class:

FailureMessage
Invalid IDInvalid <kind> ID: <value>, for example Invalid task ID: 5, Invalid row ID: "" or Invalid calendar ID: undefined (an empty string shows as "", an object or array as object or array)
Duplicate IDDuplicate <kind> ID: <id>, for example Duplicate dependency ID: d1
Unknown dependency endUnknown dependency endpoint: <dependency ID>
Unknown referenceUnknown <kind> in <owner>: <value>, where the owner is what holds the reference: Unknown resource in assignment: <id> or Unknown task in assignment: <id>; on the graph side Unknown node in graph edge <edge ID>: <node> (an edge from or to), Unknown port in graph edge <edge ID>: <port>, Unknown node in graph group <group ID>: <node>, Unknown parent group in graph group <group ID>: <parentId>, Unknown swimlane in graph node <node ID>: <lane> (laneOf), Unknown group in collapsedIds: <id>, Unknown node in roots: <id>, Unknown node in fixedIds: <id>, Unknown node in fromId: <id> and … in toId: <id> (shortestGraphPath), Unknown node in graph deletion: <id>, Unknown edge in graph deletion: <id>, Unknown node in graph clone: <id>, Unknown node in graph port rules: <id>, Unknown port in graph port rules: <port> (graph node <node ID>) and Unknown edge in graph connection check: <id>
Repeated assignmentDuplicate assignment of task <task ID> to resource <resource ID>

The kinds are task, dependency, calendar, resource, row, bar, baseline set, marker, marker range, load row, event, unplanned task, windowed data item, windowed data link, view row (the rowIds of a WindowedView), graph page node, graph page edge, column (renderTimelineSvg and GanttChart columns), graph node, graph edge, port (named ports, unique per node), graph group, group member (a node listed by two groups, or twice by one), swimlane (lanes of layoutSwimlaneGraph, renderGraphSvg and the NetworkGraph lanes prop), export group (renderGraphSvg groups), graph layout request (the requestId of buildGraphLayoutRequests), entity and view target (view bindings; a load target's resourceId uses resource), item and parent (diffStructure keys and parent keys) (snapshot diagnostics also use node, edge, group and column). Where the same check runs in a context that the message would not show, the context is appended in parentheses: (current plan) or (candidate plan) for comparePlans, (before) or (after) for diffStructure, (actual interval of task <id>) for rescheduleFromActuals, (bar <id>) for TimelineBar.baselines, (baselineIds), (baseline <number>) for the timelineFromMsProject baselineId option, (in one response) for windowed data, (in one page) for graph expansion pages, (graph node <id>) for port IDs, (graph group <id>) for a repeated group member, (createId for <source ID>) for the IDs cloneGraphElements gets from createId (an ID already used in the input is a duplicate) and (load target) for the resourceId of a load view target. The context never changes the class: invalid numbers and geometry stay RangeError, references, duplicates and cycles Error. Snapshot diagnostics carry the same texts as their message.

The prop checks of GanttChart and NetworkGraph follow the same class rule: a RangeError for invalid numbers and geometry (non-finite times, sizes that are not positive, inverted ranges, out-of-range options) and for an unknown value of a string option such as selectionMode, background, edgeStyle, routingPolicy or dependencyStyle (as the core does for an unknown layout direction), and an Error for bad references, invalid or duplicate IDs and cycles. GanttChart's own ID checks use the strict rule and the texts above, with the kinds marker, load row, zoom preset and column (for example Invalid marker ID: 3, Duplicate column ID: c); its checks of columns, load rows, header bands and markers are the ones renderTimelineSvg runs, so both report the same class and text for the same input. NetworkGraph's node, edge, port, group and lane checks use the same rule and texts (for example Invalid graph node ID: 5, Duplicate graph group ID: g, Unknown node in graph group g: zz); its group checks and collapseGraphGroups share one implementation. Checks of data that a core function validates (rows, bars, dependencies, ranges, marker ranges, baselines, non-working periods, layout options, lanes, edge bands, positions and sizes) report the core's error. Numeric prop messages keep their own clear texts that name the prop, such as tooltipDelay must be finite and nonnegative, snap must be finite and positive, minDuration must be finite and positive or snapGrid must be a positive finite number of chart units.

Released under the MIT License.