Skip to content

Commit

Permalink
throw LottieError if the fetch response is not ok
Browse files Browse the repository at this point in the history
  • Loading branch information
SkoebaSteve committed Sep 7, 2023
1 parent e446270 commit b5b7d92
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ember-lottie/src/components/lottie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ class NotFoundError extends Error {
Object.setPrototypeOf(this, NotFoundError.prototype);
}
}
class LottieError extends Error {
status: number;
statusText: string;

constructor(status: number, statusText: string) {
super(statusText);

this.name = 'LottieError';

this.status = status;
this.statusText = statusText;
}
}

export interface LottieArgs {
name?: string;
Expand Down Expand Up @@ -63,6 +76,8 @@ export default class LottieComponent extends Component<LottieSignature> {

if (response.status === 404) {
throw new NotFoundError();
} else if (!response.ok) {
throw new LottieError(response.status, response.statusText);
} else {
animationData = await response.json();
}
Expand Down

0 comments on commit b5b7d92

Please sign in to comment.