mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 22:52:08 +08:00
feat: move error response to top and enlarge window for easier debugging (#11169)
This commit is contained in:
parent
4f7d8731ea
commit
d6e7ce330e
@ -207,14 +207,15 @@ const ErrorDetailModal: React.FC<ErrorDetailModalProps> = ({ open, onClose, erro
|
|||||||
{t('common.close')}
|
{t('common.close')}
|
||||||
</Button>
|
</Button>
|
||||||
]}
|
]}
|
||||||
width={600}>
|
width="80%"
|
||||||
|
style={{ maxWidth: '1200px', minWidth: '600px' }}>
|
||||||
<ErrorDetailContainer>{renderErrorDetails(error)}</ErrorDetailContainer>
|
<ErrorDetailContainer>{renderErrorDetails(error)}</ErrorDetailContainer>
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ErrorDetailContainer = styled.div`
|
const ErrorDetailContainer = styled.div`
|
||||||
max-height: 400px;
|
max-height: 60vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -347,16 +348,8 @@ const AiSdkError = ({ error }: { error: SerializedAiSdkErrorUnion }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorDetailList>
|
<ErrorDetailList>
|
||||||
<AiSdkErrorBase error={error} />
|
|
||||||
|
|
||||||
{(isSerializedAiSdkAPICallError(error) || isSerializedAiSdkDownloadError(error)) && (
|
{(isSerializedAiSdkAPICallError(error) || isSerializedAiSdkDownloadError(error)) && (
|
||||||
<>
|
<>
|
||||||
{error.statusCode && (
|
|
||||||
<ErrorDetailItem>
|
|
||||||
<ErrorDetailLabel>{t('error.statusCode')}:</ErrorDetailLabel>
|
|
||||||
<ErrorDetailValue>{error.statusCode}</ErrorDetailValue>
|
|
||||||
</ErrorDetailItem>
|
|
||||||
)}
|
|
||||||
{error.url && (
|
{error.url && (
|
||||||
<ErrorDetailItem>
|
<ErrorDetailItem>
|
||||||
<ErrorDetailLabel>{t('error.requestUrl')}:</ErrorDetailLabel>
|
<ErrorDetailLabel>{t('error.requestUrl')}:</ErrorDetailLabel>
|
||||||
@ -374,12 +367,27 @@ const AiSdkError = ({ error }: { error: SerializedAiSdkErrorUnion }) => {
|
|||||||
<CodeViewer value={error.responseBody} className="source-view" language="json" expanded />
|
<CodeViewer value={error.responseBody} className="source-view" language="json" expanded />
|
||||||
</ErrorDetailItem>
|
</ErrorDetailItem>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{error.requestBodyValues && (
|
{(isSerializedAiSdkAPICallError(error) || isSerializedAiSdkDownloadError(error)) && (
|
||||||
|
<>
|
||||||
|
{error.statusCode && (
|
||||||
<ErrorDetailItem>
|
<ErrorDetailItem>
|
||||||
<ErrorDetailLabel>{t('error.requestBodyValues')}:</ErrorDetailLabel>
|
<ErrorDetailLabel>{t('error.statusCode')}:</ErrorDetailLabel>
|
||||||
|
<ErrorDetailValue>{error.statusCode}</ErrorDetailValue>
|
||||||
|
</ErrorDetailItem>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isSerializedAiSdkAPICallError(error) && (
|
||||||
|
<>
|
||||||
|
{error.responseHeaders && (
|
||||||
|
<ErrorDetailItem>
|
||||||
|
<ErrorDetailLabel>{t('error.responseHeaders')}:</ErrorDetailLabel>
|
||||||
<CodeViewer
|
<CodeViewer
|
||||||
value={safeToString(error.requestBodyValues)}
|
value={JSON.stringify(error.responseHeaders, null, 2)}
|
||||||
className="source-view"
|
className="source-view"
|
||||||
language="json"
|
language="json"
|
||||||
expanded
|
expanded
|
||||||
@ -387,11 +395,11 @@ const AiSdkError = ({ error }: { error: SerializedAiSdkErrorUnion }) => {
|
|||||||
</ErrorDetailItem>
|
</ErrorDetailItem>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error.responseHeaders && (
|
{error.requestBodyValues && (
|
||||||
<ErrorDetailItem>
|
<ErrorDetailItem>
|
||||||
<ErrorDetailLabel>{t('error.responseHeaders')}:</ErrorDetailLabel>
|
<ErrorDetailLabel>{t('error.requestBodyValues')}:</ErrorDetailLabel>
|
||||||
<CodeViewer
|
<CodeViewer
|
||||||
value={JSON.stringify(error.responseHeaders, null, 2)}
|
value={safeToString(error.requestBodyValues)}
|
||||||
className="source-view"
|
className="source-view"
|
||||||
language="json"
|
language="json"
|
||||||
expanded
|
expanded
|
||||||
@ -627,6 +635,8 @@ const AiSdkError = ({ error }: { error: SerializedAiSdkErrorUnion }) => {
|
|||||||
<ErrorDetailValue>{error.functionality}</ErrorDetailValue>
|
<ErrorDetailValue>{error.functionality}</ErrorDetailValue>
|
||||||
</ErrorDetailItem>
|
</ErrorDetailItem>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<AiSdkErrorBase error={error} />
|
||||||
</ErrorDetailList>
|
</ErrorDetailList>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user