Update Js for logs.html
This commit is contained in:
@@ -262,7 +262,7 @@ func (h *ProxyHandler) createModifyResponseFunc(attemptErr **errors.APIError, is
|
||||
|
||||
bodyBytes, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
*attemptErr = errors.NewAPIError(errors.ErrBadGateway, "Failed to read upstream response")
|
||||
*attemptErr = errors.NewAPIErrorWithUpstream(http.StatusBadGateway, "UPSTREAM_GATEWAY_ERROR", nil)
|
||||
resp.Body = io.NopCloser(bytes.NewReader([]byte{}))
|
||||
return nil
|
||||
}
|
||||
@@ -271,8 +271,7 @@ func (h *ProxyHandler) createModifyResponseFunc(attemptErr **errors.APIError, is
|
||||
*isSuccess = true
|
||||
*pTokens, *cTokens = extractUsage(bodyBytes)
|
||||
} else {
|
||||
parsedMsg := errors.ParseUpstreamError(bodyBytes)
|
||||
*attemptErr = errors.NewAPIErrorWithUpstream(resp.StatusCode, fmt.Sprintf("UPSTREAM_%d", resp.StatusCode), parsedMsg)
|
||||
*attemptErr = errors.NewAPIErrorWithUpstream(resp.StatusCode, fmt.Sprintf("UPSTREAM_%d", resp.StatusCode), bodyBytes)
|
||||
}
|
||||
resp.Body = io.NopCloser(bytes.NewReader(bodyBytes))
|
||||
return nil
|
||||
@@ -359,11 +358,15 @@ func (h *ProxyHandler) publishFinalLogEvent(c *gin.Context, startTime time.Time,
|
||||
if !isSuccess {
|
||||
errToLog := finalErr
|
||||
if errToLog == nil && rec != nil {
|
||||
errToLog = errors.NewAPIErrorWithUpstream(rec.Code, fmt.Sprintf("UPSTREAM_%d", rec.Code), "Request failed after all retries.")
|
||||
errToLog = errors.NewAPIErrorWithUpstream(rec.Code, fmt.Sprintf("UPSTREAM_%d", rec.Code), rec.Body.Bytes())
|
||||
}
|
||||
if errToLog != nil {
|
||||
if errToLog.Code == "" && errToLog.HTTPStatus >= 400 {
|
||||
errToLog.Code = fmt.Sprintf("UPSTREAM_%d", errToLog.HTTPStatus)
|
||||
}
|
||||
event.Error = errToLog
|
||||
event.RequestLog.ErrorCode, event.RequestLog.ErrorMessage = errToLog.Code, errToLog.Message
|
||||
event.RequestLog.Status = errToLog.Status
|
||||
}
|
||||
}
|
||||
eventData, err := json.Marshal(event)
|
||||
@@ -385,6 +388,7 @@ func (h *ProxyHandler) publishRetryLogEvent(c *gin.Context, startTime time.Time,
|
||||
if attemptErr != nil {
|
||||
retryEvent.Error = attemptErr
|
||||
retryEvent.RequestLog.ErrorCode, retryEvent.RequestLog.ErrorMessage = attemptErr.Code, attemptErr.Message
|
||||
retryEvent.RequestLog.Status = attemptErr.Status
|
||||
}
|
||||
eventData, err := json.Marshal(retryEvent)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user