Log 500 errors and also show error for direct download (#7936)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -48,6 +48,12 @@ impl ErrorResponse {
|
|||||||
|
|
||||||
impl IntoResponse for ErrorResponse {
|
impl IntoResponse for ErrorResponse {
|
||||||
fn into_response(self) -> Response {
|
fn into_response(self) -> Response {
|
||||||
|
if self.status.is_server_error() {
|
||||||
|
tracing::error!(status = %self.status, message = %self.message, "server error response");
|
||||||
|
} else if self.status.is_client_error() {
|
||||||
|
tracing::warn!(status = %self.status, message = %self.message, "client error response");
|
||||||
|
}
|
||||||
|
|
||||||
let body = Json(serde_json::json!({
|
let body = Json(serde_json::json!({
|
||||||
"message": self.message,
|
"message": self.message,
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import {
|
|||||||
type HfModelInfo,
|
type HfModelInfo,
|
||||||
type HfQuantVariant,
|
type HfQuantVariant,
|
||||||
} from '../../../api';
|
} from '../../../api';
|
||||||
|
import { toastError } from '../../../toasts';
|
||||||
|
import { errorMessage } from '../../../utils/conversionUtils';
|
||||||
|
|
||||||
const formatBytes = (bytes: number): string => {
|
const formatBytes = (bytes: number): string => {
|
||||||
if (bytes === 0) return 'unknown';
|
if (bytes === 0) return 'unknown';
|
||||||
@@ -178,14 +180,18 @@ export const HuggingFaceModelSearch = ({ onDownloadStarted }: Props) => {
|
|||||||
setDownloading((prev) => new Set(prev).add(key));
|
setDownloading((prev) => new Set(prev).add(key));
|
||||||
try {
|
try {
|
||||||
const response = await downloadHfModel({
|
const response = await downloadHfModel({
|
||||||
body: { spec },
|
body: { spec }, throwOnError: true
|
||||||
});
|
});
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
onDownloadStarted(response.data);
|
onDownloadStarted(response.data);
|
||||||
setDirectSpec('');
|
setDirectSpec('');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Direct download failed:', e);
|
toastError({
|
||||||
|
title: 'Direct download failed',
|
||||||
|
msg: 'Failed to start the download. Check the spec: ' + errorMessage(e),
|
||||||
|
});
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
setDownloading((prev) => {
|
setDownloading((prev) => {
|
||||||
const next = new Set(prev);
|
const next = new Set(prev);
|
||||||
|
|||||||
Reference in New Issue
Block a user