@@ -642,7 +642,8 @@ export class ModelManager {
642642 } ) ;
643643
644644 if ( ! response . ok ) {
645- throw new Error ( `HTTP ${ response . status } : ${ response . statusText } ` ) ;
645+ const message = await response . json ( ) ;
646+ throw new Error ( `HTTP ${ response . status } : ${ message . error . message || response . statusText } ` ) ;
646647 }
647648
648649 const data = await response . json ( ) ;
@@ -660,23 +661,24 @@ export class ModelManager {
660661
661662 return models ;
662663 } catch ( error ) {
663- console . warn ( "Failed to fetch OpenAI models, using defaults :" , error ) ;
664- return DEFAULT_MODELS . openai . map ( ( m ) => ( { ... m , isManual : false } ) ) ;
664+ console . error ( "Failed to fetch OpenAI models:" , error ) ;
665+ throw error ;
665666 }
666667 }
667668
668669 private async fetchGeminiModels (
669670 provider : ProviderConfig ,
670671 ) : Promise < ModelInfo [ ] > {
671672 try {
672- const response = await fetch ( `${ provider . apiUrl } /models?pageSize=50` , {
673+ const response = await fetch ( `${ provider . apiUrl } /models?pageSize=50&key= ${ provider . apiKey } ` , {
673674 headers : {
674675 "Content-Type" : "application/json" ,
675676 } ,
676677 } ) ;
677678
678679 if ( ! response . ok ) {
679- throw new Error ( `HTTP ${ response . status } : ${ response . statusText } ` ) ;
680+ const message = await response . json ( ) ;
681+ throw new Error ( `HTTP ${ response . status } : ${ message . error . message || response . statusText } ` ) ;
680682 }
681683
682684 const data = await response . json ( ) ;
@@ -702,12 +704,14 @@ export class ModelManager {
702704 contextLength : model . inputTokenLimit ,
703705 } ) ) ;
704706
705- return models . length > 0
706- ? models
707- : DEFAULT_MODELS . gemini . map ( ( m ) => ( { ...m , isManual : false } ) ) ;
707+ if ( models . length === 0 ) {
708+ throw new Error ( "No compatible Gemini models found" ) ;
709+ }
710+
711+ return models ;
708712 } catch ( error ) {
709- console . warn ( "Failed to fetch Gemini models, using defaults :" , error ) ;
710- return DEFAULT_MODELS . gemini . map ( ( m ) => ( { ... m , isManual : false } ) ) ;
713+ console . error ( "Failed to fetch Gemini models:" , error ) ;
714+ throw error ;
711715 }
712716 }
713717
@@ -736,8 +740,8 @@ export class ModelManager {
736740
737741 return models ;
738742 } catch ( error ) {
739- console . warn ( "Failed to fetch models from custom provider:" , error ) ;
740- return [ ] ;
743+ console . error ( "Failed to fetch models from custom provider:" , error ) ;
744+ throw error ;
741745 }
742746 }
743747
0 commit comments