fixes
This commit is contained in:
@@ -489,7 +489,7 @@ fn reject(headers: &HeaderMap, message: String) -> Response {
|
||||
/// pattern a value does not satisfy — is the user's to fix and answers 422;
|
||||
/// only an actually unreachable backend answers 502.
|
||||
fn grpc_error(headers: &HeaderMap, error: &tonic::Status) -> Response {
|
||||
crate::ui::FormError::from_status(error)
|
||||
crate::ui::FormError::from_status_with_message(error, format!("{error:?}"))
|
||||
.into_response(Locale::from_headers(headers), ui::render_error)
|
||||
}
|
||||
|
||||
@@ -509,13 +509,14 @@ fn import_error(
|
||||
return failure.into_response(locale, ui::render_error);
|
||||
}
|
||||
let status = failure.status_code();
|
||||
let backend_error = format!("{error:?}");
|
||||
let message = ui::render_import_failure(
|
||||
locale,
|
||||
inserted_before_chunk + inserted_in_chunk,
|
||||
prepared_rows,
|
||||
// One header row precedes the data, and CSV rows are one-based.
|
||||
chunk_start + failed_row_index + 2,
|
||||
failure.message(),
|
||||
&backend_error,
|
||||
);
|
||||
(status, Html(message)).into_response()
|
||||
}
|
||||
|
||||
@@ -39,7 +39,13 @@ impl FormError {
|
||||
/// on some pages and a rejected submission as an unreachable backend on
|
||||
/// others.
|
||||
pub(crate) fn from_status(status: &tonic::Status) -> Self {
|
||||
let message = status.message().to_string();
|
||||
Self::from_status_with_message(status, status.message().to_string())
|
||||
}
|
||||
|
||||
pub(crate) fn from_status_with_message(
|
||||
status: &tonic::Status,
|
||||
message: String,
|
||||
) -> Self {
|
||||
match status.code() {
|
||||
tonic::Code::Unauthenticated => Self::Unauthenticated,
|
||||
tonic::Code::PermissionDenied => Self::Forbidden(message),
|
||||
|
||||
Reference in New Issue
Block a user