Skip to content

Errors ​

Makoo uses only two error classes: MakooError and MakooAggregateError, which extends it. Every error has an error code code, used to tell error kinds apart in code. For when errors occur and how to handle them, see Error Categories and Handling.

MakooError ​

ts
class MakooError extends Error {
  readonly code: string;
  constructor(message: string, options: { code: string; cause?: unknown });
}
FieldDescription
name'MakooError'
messageSays what Makoo was doing and to what, for example Failed to mount "panel"
codeError code; see below
causeThe wrapped underlying error, such as a value thrown by an adapter or event handler. Problems Makoo detects itself, such as timeouts and target invalidation, have no cause

Expand the error object in the browser console and follow cause to find the original code location.

ts
import { MakooError, MakooErrorCode } from '@makoojs/core';

try {
  core.injection('panel').command.start();
} catch (error) {
  if (error instanceof MakooError && error.code === MakooErrorCode.INJECTION_CLOSED) {
    console.warn('panel was closed after a cleanup failure; please reload the page');
  }
}

MakooAggregateError ​

Collects multiple child errors; used for cleanup failures.

ts
class MakooAggregateError extends MakooError {
  readonly errors: readonly unknown[];
  constructor(errors: readonly unknown[], message: string, options: { code: string; cause?: unknown });
}
  • The first line of message is the summary, followed by one line per direct child error.
  • In INJECTION_CLEANUP_FAILED, if this wind-down was caused by an execution failure, that execution error comes first in errors, followed by the errors of each cleanup step; cleanup errors of attached listeners are merged in here too.
  • The errors of INSTANCE_CLEANUP_FAILED are the INJECTION_CLEANUP_FAILED of each injection, at most two levels deep.

MakooErrorCode ​

All error codes are strings with the MAKOO_ prefix. Compare using the constants, for example MakooErrorCode.TARGET_WAIT_TIMEOUT.

Configuration Errors ​

Thrown synchronously by useAdapter() or apply(); none of the declarations in the same batch start.

ConstantMeaning
DECLARATION_INVALIDapply() received an empty array, an entry is not a component, Each Injection, or listener declaration, or an attached listener sets reinject
INJECTION_NAME_CONFLICTDuplicate injection name, or duplicate attached listener names within the same component
ADAPTER_NAME_CONFLICTAn adapter with the same name is already registered
ADAPTER_NOT_FOUNDThe adapter selected by a component is not registered

Control Errors ​

The current status or context doesn't allow this call; thrown synchronously.

ConstantMeaning
INJECTION_NOT_FOUNDThe name doesn't exist, or it belongs to the other kind of injection: injection() found a standalone listener, or listener() found a component
LISTENER_NOT_FOUNDThe component has no attached listener with this name
INJECTION_REMOVEDThe injection has been removed and can't be started again
INJECTION_CLOSEDThe injection's cleanup failed earlier and it can't be started again
INSTANCE_DISPOSEDThe Core instance has been disposed

Execution Failures ​

Ends one execution, is written to lastError, and the status becomes failed. After cleanup succeeds, you can start() again.

ConstantMeaning
TARGET_WAIT_TIMEOUTThe mount target or listener target was not found within timeout
MOUNT_TARGET_DETACHEDThe mount target or component container became invalid, and reinject is not enabled
MOUNT_FAILEDThe adapter threw while mounting; the original error is in cause
LISTENER_TARGET_DETACHEDThe listener target left the page, and recovery is not allowed
LISTENER_BIND_FAILEDBinding the event threw
ATTACHED_LISTENER_FAILEDAn attached listener failure ended the owning component; the child error is in cause

Cleanup Failures ​

Core can't confirm that all resources were released, and the injection is closed (later start() calls throw INJECTION_CLOSED).

ConstantMeaning
UNMOUNT_FAILEDThe adapter threw while unmounting
CONTAINER_REMOVE_FAILEDRemoving the component container failed
LISTENER_UNBIND_FAILEDUnbinding the event failed
MOUNT_CLEANUP_FAILEDFor the adapter contract: thrown when the adapter also fails to release resources after a mount failure. Core unpacks it, so what you see in lastError is INJECTION_CLEANUP_FAILED, containing MOUNT_FAILED followed by each release error
INJECTION_CLEANUP_FAILEDSummary of one wind-down of one injection, a MakooAggregateError
INSTANCE_CLEANUP_FAILEDSummary of dispose(), a MakooAggregateError

Callback Errors ​

User code called by Makoo threw; only reported, without changing status.

ConstantMeaning
LISTENER_CALLBACK_FAILEDAn event handler threw or returned a rejected Promise
STATE_SUBSCRIBER_FAILEDA status subscriber threw
INSTANCE_OBSERVER_FAILEDAn observe() callback threw

Adapter Error Codes ​

ConstantPackageMeaning
VueErrorCode.VUE_HOOK_OUTSIDE_COMPONENT@makoojs/vueMakoo's injection context isn't available when calling useMakooComponent(): not in a Vue app mounted by Makoo, or not called synchronously in setup (for example, in an event handler or setTimeout)
VueErrorCode.VUE_HOOK_OUTSIDE_SCOPE@makoojs/vueThe injection context is available but there is no effect scope, for example when called in a plugin through app.runWithContext()
VueErrorCode.VUE_PARTIAL_MOUNT_UNCONFIRMED@makoojs/vueVue mounting failed midway and cleanup can't be confirmed; the injection is closed as a result
ReactErrorCode.REACT_HOOK_OUTSIDE_COMPONENT@makoojs/reactMakoo hooks were called outside a React component mounted by Makoo