diff --git a/src/common/owl_error.ts b/src/common/owl_error.ts new file mode 100644 index 00000000..180fdd2c --- /dev/null +++ b/src/common/owl_error.ts @@ -0,0 +1,4 @@ +// Custom error class that wraps error that happen in the owl lifecycle +export class OwlError extends Error { + cause?: any; +} diff --git a/src/compiler/code_generator.ts b/src/compiler/code_generator.ts index 3c0d6498..0220afb0 100644 --- a/src/compiler/code_generator.ts +++ b/src/compiler/code_generator.ts @@ -29,7 +29,7 @@ import { Attrs, EventHandlers, } from "./parser"; -import { OwlError } from "../runtime/error_handling"; +import { OwlError } from "../common/owl_error"; type BlockType = "block" | "text" | "multi" | "list" | "html" | "comment"; const whitespaceRE = /\s+/g; diff --git a/src/compiler/index.ts b/src/compiler/index.ts index d79e9534..16683bc1 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -2,7 +2,7 @@ import type { TemplateSet } from "../runtime/template_set"; import type { BDom } from "../runtime/blockdom"; import { CodeGenerator, Config } from "./code_generator"; import { parse } from "./parser"; -import { OwlError } from "../runtime"; +import { OwlError } from "../common/owl_error"; export type Template = (context: any, vnode: any, key?: string) => BDom; diff --git a/src/compiler/inline_expressions.ts b/src/compiler/inline_expressions.ts index d9e866b1..af531df0 100644 --- a/src/compiler/inline_expressions.ts +++ b/src/compiler/inline_expressions.ts @@ -1,4 +1,4 @@ -import { OwlError } from "../runtime/error_handling"; +import { OwlError } from "../common/owl_error"; /** * Owl QWeb Expression Parser diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5576f294..555835a0 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1,4 +1,4 @@ -import { OwlError } from "../runtime/error_handling"; +import { OwlError } from "../common/owl_error"; // ----------------------------------------------------------------------------- // AST Type definition diff --git a/src/runtime/app.ts b/src/runtime/app.ts index 3abba10f..9e8a99f3 100644 --- a/src/runtime/app.ts +++ b/src/runtime/app.ts @@ -1,7 +1,8 @@ import { version } from "../version"; import { Component, ComponentConstructor, Props } from "./component"; import { ComponentNode } from "./component_node"; -import { nodeErrorHandlers, OwlError, handleError } from "./error_handling"; +import { nodeErrorHandlers, handleError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; import { Fiber, RootFiber, MountOptions } from "./fibers"; import { Scheduler } from "./scheduler"; import { validateProps } from "./template_helpers"; diff --git a/src/runtime/blockdom/block_compiler.ts b/src/runtime/blockdom/block_compiler.ts index e67d7132..cbc91e7d 100644 --- a/src/runtime/blockdom/block_compiler.ts +++ b/src/runtime/blockdom/block_compiler.ts @@ -1,4 +1,4 @@ -import { OwlError } from "../error_handling"; +import { OwlError } from "../../common/owl_error"; import { attrsSetter, attrsUpdater, createAttrUpdater, setClass, updateClass } from "./attributes"; import { config } from "./config"; import { createEventHandler } from "./events"; diff --git a/src/runtime/component_node.ts b/src/runtime/component_node.ts index 98f580a4..bffc0fc5 100644 --- a/src/runtime/component_node.ts +++ b/src/runtime/component_node.ts @@ -1,7 +1,8 @@ import type { App, Env } from "./app"; import { BDom, VNode } from "./blockdom"; import { Component, ComponentConstructor, Props } from "./component"; -import { fibersInError, OwlError } from "./error_handling"; +import { fibersInError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; import { Fiber, makeChildFiber, makeRootFiber, MountFiber, MountOptions } from "./fibers"; import { clearReactivesForCallback, getSubscriptions, reactive, targets } from "./reactivity"; import { STATUS } from "./status"; diff --git a/src/runtime/error_handling.ts b/src/runtime/error_handling.ts index 27354756..275e138b 100644 --- a/src/runtime/error_handling.ts +++ b/src/runtime/error_handling.ts @@ -1,11 +1,7 @@ +import { OwlError } from "../common/owl_error"; import type { ComponentNode } from "./component_node"; import type { Fiber } from "./fibers"; -// Custom error class that wraps error that happen in the owl lifecycle -export class OwlError extends Error { - cause?: any; -} - // Maps fibers to thrown errors export const fibersInError: WeakMap = new WeakMap(); export const nodeErrorHandlers: WeakMap void)[]> = new WeakMap(); diff --git a/src/runtime/event_handling.ts b/src/runtime/event_handling.ts index d7607b33..eed46b92 100644 --- a/src/runtime/event_handling.ts +++ b/src/runtime/event_handling.ts @@ -1,6 +1,6 @@ import { filterOutModifiersFromData } from "./blockdom/config"; import { STATUS } from "./status"; -import { OwlError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; export const mainEventHandler = (data: any, ev: Event, currentTarget?: EventTarget | null) => { const { data: _data, modifiers } = filterOutModifiersFromData(data); diff --git a/src/runtime/fibers.ts b/src/runtime/fibers.ts index ca43a502..13b2124d 100644 --- a/src/runtime/fibers.ts +++ b/src/runtime/fibers.ts @@ -1,6 +1,7 @@ import { BDom, mount } from "./blockdom"; import type { ComponentNode } from "./component_node"; -import { fibersInError, OwlError } from "./error_handling"; +import { fibersInError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; import { STATUS } from "./status"; export function makeChildFiber(node: ComponentNode, parent: Fiber): Fiber { diff --git a/src/runtime/index.ts b/src/runtime/index.ts index 1813ce77..651263a9 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -55,7 +55,7 @@ export { onError, } from "./lifecycle_hooks"; export { validate, validateType } from "./validation"; -export { OwlError } from "./error_handling"; +export { OwlError } from "../common/owl_error"; export const __info__ = { version: App.version, diff --git a/src/runtime/lifecycle_hooks.ts b/src/runtime/lifecycle_hooks.ts index 4074d3fd..0c98cbe8 100644 --- a/src/runtime/lifecycle_hooks.ts +++ b/src/runtime/lifecycle_hooks.ts @@ -1,5 +1,6 @@ import { getCurrent } from "./component_node"; -import { nodeErrorHandlers, OwlError } from "./error_handling"; +import { nodeErrorHandlers } from "./error_handling"; +import { OwlError } from "../common/owl_error"; const TIMEOUT = Symbol("timeout"); function wrapError(fn: (...args: any[]) => any, hookName: string) { diff --git a/src/runtime/portal.ts b/src/runtime/portal.ts index 37ba8a32..72d40538 100644 --- a/src/runtime/portal.ts +++ b/src/runtime/portal.ts @@ -1,7 +1,7 @@ import { onMounted, onWillUnmount } from "./lifecycle_hooks"; import { BDom, text, VNode } from "./blockdom"; import { Component } from "./component"; -import { OwlError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; const VText: any = text("").constructor; diff --git a/src/runtime/reactivity.ts b/src/runtime/reactivity.ts index f5e75d2a..210e38ec 100644 --- a/src/runtime/reactivity.ts +++ b/src/runtime/reactivity.ts @@ -1,5 +1,5 @@ import type { Callback } from "./utils"; -import { OwlError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; // Special key to subscribe to, to be notified of key creation/deletion const KEYCHANGES = Symbol("Key changes"); diff --git a/src/runtime/template_helpers.ts b/src/runtime/template_helpers.ts index 7c553b07..242dcf2b 100644 --- a/src/runtime/template_helpers.ts +++ b/src/runtime/template_helpers.ts @@ -4,7 +4,7 @@ import { html } from "./blockdom/index"; import { isOptional, validateSchema } from "./validation"; import type { ComponentConstructor } from "./component"; import { markRaw } from "./reactivity"; -import { OwlError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; import type { ComponentNode } from "./component_node"; const ObjectCreate = Object.create; diff --git a/src/runtime/template_set.ts b/src/runtime/template_set.ts index 83bc4450..4bcbe43e 100644 --- a/src/runtime/template_set.ts +++ b/src/runtime/template_set.ts @@ -3,7 +3,7 @@ import { comment, createBlock, html, list, multi, text, toggler } from "./blockd import { getCurrent } from "./component_node"; import { Portal, portalTemplate } from "./portal"; import { helpers } from "./template_helpers"; -import { OwlError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; const bdom = { text, createBlock, list, multi, html, toggler, comment }; diff --git a/src/runtime/utils.ts b/src/runtime/utils.ts index 143e76d8..7aa9b112 100644 --- a/src/runtime/utils.ts +++ b/src/runtime/utils.ts @@ -1,4 +1,4 @@ -import { OwlError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; export type Callback = () => void; /** diff --git a/src/runtime/validation.ts b/src/runtime/validation.ts index 8f657f7b..29063fd4 100644 --- a/src/runtime/validation.ts +++ b/src/runtime/validation.ts @@ -1,4 +1,4 @@ -import { OwlError } from "./error_handling"; +import { OwlError } from "../common/owl_error"; import { toRaw } from "./reactivity"; type BaseType = diff --git a/tests/components/error_handling.test.ts b/tests/components/error_handling.test.ts index a444125c..b5fecf5a 100644 --- a/tests/components/error_handling.test.ts +++ b/tests/components/error_handling.test.ts @@ -20,7 +20,7 @@ import { useLogLifecycle, nextAppError, } from "../helpers"; -import { OwlError } from "../../src/runtime/error_handling"; +import { OwlError } from "../../src/common/owl_error"; let fixture: HTMLElement; diff --git a/tests/components/style_class.test.ts b/tests/components/style_class.test.ts index d2d0db5f..e57dcd5e 100644 --- a/tests/components/style_class.test.ts +++ b/tests/components/style_class.test.ts @@ -1,4 +1,4 @@ -import { OwlError } from "../../src/runtime/error_handling"; +import { OwlError } from "../../src/common/owl_error"; import { App, Component, mount, onMounted, useState, xml } from "../../src"; import { makeTestFixture, nextAppError, nextTick, snapshotEverything } from "../helpers"; diff --git a/tests/helpers.ts b/tests/helpers.ts index eaef3d8b..c28b2c17 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -19,7 +19,7 @@ import { helpers } from "../src/runtime/template_helpers"; import { TemplateSet, globalTemplates } from "../src/runtime/template_set"; import { BDom } from "../src/runtime/blockdom"; import { compile } from "../src/compiler"; -import { OwlError } from "../src/runtime/error_handling"; +import { OwlError } from "../src/common/owl_error"; const mount = blockDom.mount; diff --git a/tests/misc/portal.test.ts b/tests/misc/portal.test.ts index 8e5d0e87..e07d524f 100644 --- a/tests/misc/portal.test.ts +++ b/tests/misc/portal.test.ts @@ -1,4 +1,4 @@ -import { OwlError } from "../../src/runtime/error_handling"; +import { OwlError } from "../../src/common/owl_error"; import { App, Component,