(newApiErr *types.NewAPIError, statusCodeMappingStr string)
| 112 | } |
| 113 | |
| 114 | func ResetStatusCode(newApiErr *types.NewAPIError, statusCodeMappingStr string) { |
| 115 | if statusCodeMappingStr == "" || statusCodeMappingStr == "{}" { |
| 116 | return |
| 117 | } |
| 118 | statusCodeMapping := make(map[string]string) |
| 119 | err := json.Unmarshal([]byte(statusCodeMappingStr), &statusCodeMapping) |
| 120 | if err != nil { |
| 121 | return |
| 122 | } |
| 123 | if newApiErr.StatusCode == http.StatusOK { |
| 124 | return |
| 125 | } |
| 126 | codeStr := strconv.Itoa(newApiErr.StatusCode) |
| 127 | if _, ok := statusCodeMapping[codeStr]; ok { |
| 128 | intCode, _ := strconv.Atoi(statusCodeMapping[codeStr]) |
| 129 | newApiErr.StatusCode = intCode |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | func TaskErrorWrapperLocal(err error, code string, statusCode int) *dto.TaskError { |
| 134 | openaiErr := TaskErrorWrapper(err, code, statusCode) |
no outgoing calls
no test coverage detected