Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: error handling for missing footprint #253

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/components/base-components/NormalComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
* }
* }
*/

class MissingFootprintError extends Error {
constructor(message: string) {
super(message)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at new Board (1:23) at /home/runner/work/core/core/tests/readme.test.tsx:8:17

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at new Board (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5) at renderRootSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18616:7)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Resistor (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5) at renderRootSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18616:7)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at new Board (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at new Board (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at new Board (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Chip (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5) at renderRootSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18616:7)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at new Board (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5)

Check failure on line 68 in lib/components/base-components/NormalComponent.ts

View workflow job for this annotation

GitHub Actions / test

MissingFootprintError: Footprint is missing

at new MissingFootprintError (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:68:5) at _addChildrenFromStringFootprint (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:224:13) at new NormalComponent (/home/runner/work/core/core/lib/components/base-components/NormalComponent.ts:84:10) at new Group (1:23) at new Board (1:23) at createInstance (/home/runner/work/core/core/lib/fiber/create-instance-from-react-element.ts:60:30) at completeWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:13643:28) at completeUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18775:16) at performUnitOfWork (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18750:5) at workLoopSync (/home/runner/work/core/core/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5)
this.name = "MissingFootprintError"
}
}

export class NormalComponent<
ZodProps extends ZodType = any,
PortNames extends string = never,
Expand Down Expand Up @@ -212,7 +220,9 @@
_addChildrenFromStringFootprint() {
let { footprint } = this.props
footprint ??= this._getImpliedFootprintString?.()
if (!footprint) return
if (!footprint) {
throw new MissingFootprintError("Footprint is missing")
}
if (typeof footprint === "string") {
const fpSoup = fp.string(footprint).soup()
const fpComponents = createComponentsFromSoup(fpSoup as any) // Remove as any when footprinter gets updated
Expand Down
Loading