Replace panic with error handling in connector handlers
The connector initiate and complete HTTP handlers used panic for operational errors (network, DB, provider failures). No recovery middleware exists on the console chi router, so these panics produced incomplete responses instead of proper HTTP 500 errors. Use the same log-and-render pattern already established in loadExistingConnector error handling. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -116,7 +116,9 @@ func handleConnectorInitiate(
|
||||
|
||||
redirectURL, err := connectorRegistry.Initiate(r.Context(), provider, organizationID, opts, r)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot initiate connector: %w", err))
|
||||
logger.ErrorCtx(r.Context(), "cannot initiate connector", log.Error(err))
|
||||
httpserver.RenderError(w, http.StatusInternalServerError, fmt.Errorf("internal error"))
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, redirectURL, http.StatusSeeOther)
|
||||
@@ -158,4 +160,3 @@ func loadExistingConnector(
|
||||
}
|
||||
return found, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user