@@ -5102,10 +5102,10 @@ async function handleGatewayFormSubmit(e) {
51025102 body : formData ,
51035103 } ,
51045104 ) ;
5105-
51065105 const result = await response . json ( ) ;
5107- if ( ! result . success ) {
5108- throw new Error ( result . message || "An error occurred" ) ;
5106+
5107+ if ( ! result || ! result . success ) {
5108+ throw new Error ( result ?. message || "Failed to add gateway" ) ;
51095109 } else {
51105110 const redirectUrl = isInactiveCheckedBool
51115111 ? `${ window . ROOT_PATH } /admin?include_inactive=true#gateways`
@@ -5166,10 +5166,9 @@ async function handleResourceFormSubmit(e) {
51665166 body : formData ,
51675167 } ,
51685168 ) ;
5169-
51705169 const result = await response . json ( ) ;
5171- if ( ! result . success ) {
5172- throw new Error ( result . message || "An error occurred " ) ;
5170+ if ( ! result || ! result . success ) {
5171+ throw new Error ( result ? .message || "Failed to add Resource " ) ;
51735172 } else {
51745173 const redirectUrl = isInactiveCheckedBool
51755174 ? `${ window . ROOT_PATH } /admin?include_inactive=true#resources`
@@ -5225,10 +5224,9 @@ async function handlePromptFormSubmit(e) {
52255224 body : formData ,
52265225 } ,
52275226 ) ;
5228-
52295227 const result = await response . json ( ) ;
5230- if ( ! result . success ) {
5231- throw new Error ( result . message || "An error occurred " ) ;
5228+ if ( ! result || ! result . success ) {
5229+ throw new Error ( result ? .message || "Failed to add prompt " ) ;
52325230 }
52335231 // Only redirect on success
52345232 const redirectUrl = isInactiveCheckedBool
@@ -5282,8 +5280,8 @@ async function handleEditPromptFormSubmit(e) {
52825280 } ) ;
52835281
52845282 const result = await response . json ( ) ;
5285- if ( ! result . success ) {
5286- throw new Error ( result . message || "An error occurred " ) ;
5283+ if ( ! result || ! result . success ) {
5284+ throw new Error ( result ? .message || "Failed to edit Prompt " ) ;
52875285 }
52885286 // Only redirect on success
52895287 const redirectUrl = isInactiveCheckedBool
@@ -5333,10 +5331,9 @@ async function handleServerFormSubmit(e) {
53335331 redirect : "manual" ,
53345332 } ,
53355333 ) ;
5336-
53375334 const result = await response . json ( ) ;
5338- if ( ! result . success ) {
5339- throw new Error ( result . message || "Failed to add server." ) ;
5335+ if ( ! result || ! result . success ) {
5336+ throw new Error ( result ? .message || "Failed to add server." ) ;
53405337 } else {
53415338 // Success redirect
53425339 const redirectUrl = isInactiveCheckedBool
@@ -5416,10 +5413,9 @@ async function handleToolFormSubmit(event) {
54165413 body : formData ,
54175414 } ,
54185415 ) ;
5419-
54205416 const result = await response . json ( ) ;
5421- if ( ! result . success ) {
5422- throw new Error ( result . message || "An error occurred " ) ;
5417+ if ( ! result || ! result . success ) {
5418+ throw new Error ( result ? .message || "Failed to add tool " ) ;
54235419 } else {
54245420 const redirectUrl = isInactiveCheckedBool
54255421 ? `${ window . ROOT_PATH } /admin?include_inactive=true#tools`
@@ -5470,11 +5466,10 @@ async function handleEditToolFormSubmit(event) {
54705466 body : formData ,
54715467 headers : { "X-Requested-With" : "XMLHttpRequest" } ,
54725468 } ) ;
5473- console . log ( "response:" , response ) ;
5469+
54745470 const result = await response . json ( ) ;
5475- console . log ( "result edit tool form:" , result ) ;
5476- if ( ! result . success ) {
5477- throw new Error ( result . message || "An error occurred" ) ;
5471+ if ( ! result || ! result . success ) {
5472+ throw new Error ( result ?. message || "Failed to edit tool" ) ;
54785473 } else {
54795474 const redirectUrl = isInactiveCheckedBool
54805475 ? `${ window . ROOT_PATH } /admin?include_inactive=true#tools`
@@ -5536,10 +5531,9 @@ async function handleEditGatewayFormSubmit(e) {
55365531 method : "POST" ,
55375532 body : formData ,
55385533 } ) ;
5539-
55405534 const result = await response . json ( ) ;
5541- if ( ! result . success ) {
5542- throw new Error ( result . message || "An error occurred " ) ;
5535+ if ( ! result || ! result . success ) {
5536+ throw new Error ( result ? .message || "Failed to edit gateway " ) ;
55435537 }
55445538 // Only redirect on success
55455539 const redirectUrl = isInactiveCheckedBool
@@ -5581,10 +5575,9 @@ async function handleEditServerFormSubmit(e) {
55815575 method : "POST" ,
55825576 body : formData ,
55835577 } ) ;
5584-
55855578 const result = await response . json ( ) ;
5586- if ( ! result . success ) {
5587- throw new Error ( result . message || "An error occurred " ) ;
5579+ if ( ! result || ! result . success ) {
5580+ throw new Error ( result ? .message || "Failed to edit server " ) ;
55885581 }
55895582 // Only redirect on success
55905583 else {
@@ -5639,8 +5632,8 @@ async function handleEditResFormSubmit(e) {
56395632 } ) ;
56405633
56415634 const result = await response . json ( ) ;
5642- if ( ! result . success ) {
5643- throw new Error ( result . message || "An error occurred " ) ;
5635+ if ( ! result || ! result . success ) {
5636+ throw new Error ( result ? .message || "Failed to edit resource " ) ;
56445637 }
56455638 // Only redirect on success
56465639 else {
0 commit comments