@@ -79,7 +79,11 @@ async function configUpdateTo1115() {
7979 modelConfigNew = { "provider" : "openai" } ;
8080 }
8181
82- await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelConfigNew , vscode . ConfigurationTarget . Global ) ;
82+ try {
83+ await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelConfigNew , vscode . ConfigurationTarget . Global ) ;
84+ } catch ( error ) {
85+ logger . channel ( ) ?. error ( `update Model.ERNIE-Bot error: ${ error } ` ) ;
86+ }
8387 }
8488 }
8589}
@@ -196,12 +200,20 @@ async function configUpdate0912To0924() {
196200
197201 delete modelProperties [ "api_key" ] ;
198202 delete modelProperties [ "api_base" ] ;
199- await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelProperties , vscode . ConfigurationTarget . Global ) ;
203+ try {
204+ await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelProperties , vscode . ConfigurationTarget . Global ) ;
205+ } catch ( error ) {
206+ logger . channel ( ) ?. error ( `error: ${ error } ` ) ;
207+ }
200208 } else {
201209 if ( ! modelProperties [ "provider" ] ) {
202210 delete modelProperties [ "api_base" ] ;
203211 modelProperties [ "provider" ] = "devchat" ;
204- await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelProperties , vscode . ConfigurationTarget . Global ) ;
212+ try {
213+ await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelProperties , vscode . ConfigurationTarget . Global ) ;
214+ } catch ( error ) {
215+ logger . channel ( ) ?. error ( `error: ${ error } ` ) ;
216+ }
205217 }
206218 }
207219 }
@@ -224,7 +236,11 @@ async function configUpdateto240205() {
224236 if ( modelConfig1 && Object . keys ( modelConfig1 ) . length === 0 ) {
225237 let modelConfigNew = { } ;
226238 modelConfigNew = { "provider" : "devchat" } ;
227- await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelConfigNew , vscode . ConfigurationTarget . Global ) ;
239+ try {
240+ await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelConfigNew , vscode . ConfigurationTarget . Global ) ;
241+ } catch ( error ) {
242+ logger . channel ( ) ?. error ( `error: ${ error } ` ) ;
243+ }
228244 }
229245 }
230246}
@@ -262,7 +278,11 @@ async function updateInvalidSettings() {
262278 delete modelProperties [ "api_key" ] ;
263279 delete modelProperties [ "api_base" ] ;
264280 modelProperties [ "provider" ] = "devchat" ;
265- await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelProperties , vscode . ConfigurationTarget . Global ) ;
281+ try {
282+ await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelProperties , vscode . ConfigurationTarget . Global ) ;
283+ } catch ( error ) {
284+ logger . channel ( ) ?. error ( `error: ${ error } ` ) ;
285+ }
266286 }
267287 }
268288 }
@@ -271,7 +291,11 @@ async function updateInvalidSettings() {
271291async function updateInvalidDefaultModel ( ) {
272292 const defaultModel : any = UiUtilWrapper . getConfiguration ( "devchat" , "defaultModel" ) ;
273293 if ( defaultModel === "gpt-3.5-turbo-1106" || defaultModel === "gpt-3.5-turbo-16k" ) {
274- await vscode . workspace . getConfiguration ( "devchat" ) . update ( "defaultModel" , "gpt-3.5-turbo" , vscode . ConfigurationTarget . Global ) ;
294+ try {
295+ await vscode . workspace . getConfiguration ( "devchat" ) . update ( "defaultModel" , "gpt-3.5-turbo" , vscode . ConfigurationTarget . Global ) ;
296+ } catch ( error ) {
297+ logger . channel ( ) ?. error ( `update Model.ERNIE-Bot error: ${ error } ` ) ;
298+ }
275299 }
276300}
277301
@@ -320,8 +344,11 @@ async function configSetModelDefaultParams() {
320344 const modelConfig : any = UiUtilWrapper . getConfiguration ( "devchat" , model ) ;
321345 if ( ! modelConfig [ "max_input_tokens" ] ) {
322346 modelConfig [ "max_input_tokens" ] = modelParams [ model ] [ "max_input_tokens" ] ;
323- await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelConfig , vscode . ConfigurationTarget . Global ) ;
324-
347+ try {
348+ await vscode . workspace . getConfiguration ( "devchat" ) . update ( model , modelConfig , vscode . ConfigurationTarget . Global ) ;
349+ } catch ( error ) {
350+ logger . channel ( ) ?. error ( `update Model.ERNIE-Bot error: ${ error } ` ) ;
351+ }
325352 }
326353 }
327354}
0 commit comments