Skip to main content
Version: 4.11.4

Handling errors

All known Flicking errors are thrown as FlickingError with a `code` property set as listed on the ERROR_CODE.

A common use-case for this is when you're calling a prev / next / moveTo of Flicking which can throw an error when Flicking's already animating.

import { FlickingError, ERROR_CODE } from "@egjs/flicking";

try {
await flicking.next();
} catch (err) {
if (err instanceof FlickingError) {
if (err.code === ERROR_CODE.ANIMATION_ALREADY_PLAYING) {
console.error("Animation is already playing!");
} else if (err.code === ERROR_CODE.ANIMATION_INTERRUPTED) {
console.error("Animation is interrupted by user.");
}
}
}

See all possible error codes at ERROR_CODE.