@@ -10,7 +10,7 @@ import { AudioSource } from '../../sources';
1010import { RangeDeserializer } from './media.deserializer' ;
1111import { serializable , } from '../../services' ;
1212import { replaceKeyframes } from '../clip/clip.utils' ;
13- import { ValidationError } from '../../errors' ;
13+ import { ReferenceError , ValidationError } from '../../errors' ;
1414import { Clip } from '../clip' ;
1515
1616import type { CaptionPresetStrategy , CaptionTrack } from '../../tracks' ;
@@ -164,7 +164,10 @@ export class MediaClip<Props extends MediaClipProps = MediaClipProps> extends Cl
164164 public seek ( time : Timestamp ) : Promise < void > {
165165 return new Promise ( ( resolve , reject ) => {
166166 if ( ! this . element ) {
167- return reject ( new Error ( "Can't seek on element becaused it's not defined" ) ) ;
167+ return reject ( new ReferenceError ( {
168+ code : 'elementNotDefined' ,
169+ message : 'Cannot seek on undefined element' ,
170+ } ) ) ;
168171 }
169172 if ( time . millis < this . start . millis || time . millis > this . stop . millis ) {
170173 time = this . start ;
@@ -194,7 +197,10 @@ export class MediaClip<Props extends MediaClipProps = MediaClipProps> extends Cl
194197
195198 // start is larger than the stop
196199 if ( start . millis >= stop . millis ) {
197- throw new Error ( "Start can't lower than or equal the stop" ) ;
200+ throw new ValidationError ( {
201+ code : 'invalidKeyframe' ,
202+ message : "Start can't lower than or equal the stop"
203+ } ) ;
198204 }
199205 // start and/or stop are out of bounds
200206 if ( start . millis < 0 ) {
@@ -240,10 +246,16 @@ export class MediaClip<Props extends MediaClipProps = MediaClipProps> extends Cl
240246
241247 // invalid cases
242248 if ( ! time || time . millis <= this . start . millis || time . millis >= this . stop . millis ) {
243- throw new Error ( "Cannot split clip at the specified time" )
249+ throw new ValidationError ( {
250+ code : 'invalidKeyframe' ,
251+ message : 'Cannot split clip at the specified time' ,
252+ } ) ;
244253 }
245254 if ( ! this . track ) {
246- throw new Error ( 'Split must be connected to a track' )
255+ throw new ReferenceError ( {
256+ code : 'trackNotDefined' ,
257+ message : 'Clip must be attached to a track' ,
258+ } ) ;
247259 }
248260
249261 // slice relative to the offset
@@ -267,7 +279,7 @@ export class MediaClip<Props extends MediaClipProps = MediaClipProps> extends Cl
267279 public async addCaptions ( strategy ?: CaptionPresetStrategy | ( new ( ) => CaptionPresetStrategy ) ) : Promise < CaptionTrack > {
268280 if ( ! this . track ?. composition ) {
269281 throw new ValidationError ( {
270- i18n : 'compositionNotDefined' ,
282+ code : 'compositionNotDefined' ,
271283 message : 'Captions can only be generated after the clip has been added to the composition' ,
272284 } ) ;
273285 }
0 commit comments