| 125 | } |
| 126 | |
| 127 | func (e *NewAPIError) ToClaudeError() ClaudeError { |
| 128 | switch e.ErrorType { |
| 129 | case ErrorTypeOpenAIError: |
| 130 | openAIError := e.RelayError.(OpenAIError) |
| 131 | return ClaudeError{ |
| 132 | Message: e.Error(), |
| 133 | Type: fmt.Sprintf("%v", openAIError.Code), |
| 134 | } |
| 135 | case ErrorTypeClaudeError: |
| 136 | return e.RelayError.(ClaudeError) |
| 137 | default: |
| 138 | return ClaudeError{ |
| 139 | Message: e.Error(), |
| 140 | Type: string(e.ErrorType), |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func NewError(err error, errorCode ErrorCode) *NewAPIError { |
| 146 | return &NewAPIError{ |