@@ -4,6 +4,7 @@ const QvacResponse = require('@qvac/response')
44const QvacLogger = require ( '@qvac/logging' )
55const ffmpeg = require ( 'bare-ffmpeg' )
66const BaseInference = require ( '@qvac/infer-base/WeightsProvider/BaseInference' )
7+ const { QvacErrorDecoderAudio, ERR_CODES } = require ( './utils/error' )
78
89/**
910 * FFmpeg-based audio decoder (single-threaded)
@@ -106,7 +107,10 @@ class FFmpegDecoder extends BaseInference {
106107
107108 // Validate audio format
108109 if ( ! this . SUPPORTED_AUDIO_FORMATS [ this . config . audioFormat ] ) {
109- throw new Error ( `Unsupported audio format: ${ this . config . audioFormat } ` )
110+ throw new QvacErrorDecoderAudio ( {
111+ code : ERR_CODES . UNSUPPORTED_AUDIO_FORMAT ,
112+ adds : this . config . audioFormat
113+ } )
110114 }
111115
112116 this . isLoaded = true
@@ -135,7 +139,7 @@ class FFmpegDecoder extends BaseInference {
135139 */
136140 async run ( audioStream ) {
137141 if ( ! this . isLoaded ) {
138- throw new Error ( 'Decoder not loaded. Call load() first.' )
142+ throw new QvacErrorDecoderAudio ( { code : ERR_CODES . DECODER_NOT_LOADED } )
139143 }
140144
141145 this . logger . info ( 'Starting new audio stream processing' )
@@ -397,7 +401,10 @@ class FFmpegDecoder extends BaseInference {
397401
398402 const streamIndex = this . config . streamIndex || 0
399403 if ( format . streams [ streamIndex ] === undefined ) {
400- throw new Error ( 'Stream index out of bounds' )
404+ throw new QvacErrorDecoderAudio ( {
405+ code : ERR_CODES . STREAM_INDEX_OUT_OF_BOUNDS ,
406+ adds : streamIndex
407+ } )
401408 }
402409
403410 // Process the stream and generate decoded output
0 commit comments