본문으로 건너뛰기
버전: Next

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.