Errors
There is no editor-wide branded error hierarchy. @oh-just-another/editor itself exports no error classes โ failures surface as ordinary thrown Error instances, null returns, and console diagnostics. Typed errors exist where a stable contract matters: serialization.
Serialization errorsโ
@oh-just-another/serialization exports two error classes:
DeserializationErrorโ thrown bydeserializeScene/parseScenewhen validation fails (non-object input, document version newer than the build, schema mismatch). Carries the failure cause inreason(az.ZodErrorfor schema failures).MissingMigrationErrorโ thrown byrunMigrationswhen no migration is registered for a version step.
import { parseScene, DeserializationError } from "@oh-just-another/serialization";
try {
const scene = parseScene(json);
} catch (error) {
if (error instanceof DeserializationError) {
console.error("Invalid scene document", error.message, error.reason);
}
}
Null returns instead of throwsโ
Operations that can legitimately produce nothing return null rather than throwing. exportSceneToPng returns null for an empty scene or when OffscreenCanvas is unavailable:
import { exportSceneToPng } from "@oh-just-another/editor";
const blob = await exportSceneToPng(scene, {
background: "color",
backgroundColor: "#ffffff",
scale: 2,
});
if (!blob) {
// empty scene or no OffscreenCanvas support
}
Diagnosticsโ
- Capability detection is logged via
logCapabilitiesat boot, so renderer/WASM/worker misconfiguration is visible in DevTools. - Listener exceptions in the
@oh-just-another/eventsemitter do not abort the emit loop โ remaining listeners still run and the first error is re-thrown afterwards.