feat: Excel/CSVのダウンロード時のエラーメッセージを修正

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-09-04 16:43:45 +09:00
parent ce122ee898
commit a8258b3f88
2 changed files with 10 additions and 27 deletions

View File

@ -9,7 +9,6 @@ from starlette import status
from src.depends.auth import verify_session
from src.depends.services import get_service
from src.error.exceptions import DBException
from src.logging.get_logger import get_logger
from src.model.internal.session import UserSession
from src.model.request.bio import BioModel
@ -114,7 +113,7 @@ def _search_bio_data(
search_param, limitation=environment.BIO_EXCEL_RESULT_MAX_COUNT)
elif download_param.ext == 'csv':
search_result_df, query = bio_service.search_download_bio_data(search_param)
except DBException as e:
except Exception as e:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail={'error': 'db_error', 'message': e.args}

View File

@ -243,26 +243,28 @@
loading.stop();
$(`#modal_${ext}`).modal('toggle');
} catch (e) {
alert("エラーが発生しました。:" + e.message);
// 予期せぬエラーが発生した場合
loading.stop();
$(`#modal_${ext}`).modal('toggle');
$(`#ErrorModal_Unexpected`).modal('toggle');
return
}
},
error: function(jqXHR, textStatus, errorThrown) {
loading.stop()
const responseJson = jqXHR.responseJSON
if (responseJson?.detail?.error === 'db_error') {
loading.stop()
$(`#modal_${ext}`).modal('toggle');
$(`#ErrorModal_DB`).modal('toggle');
return
}
if (responseJson?.detail?.error === 'aws_error') {
loading.stop();
$(`#modal_${ext}`).modal('toggle');
$(`#ErrorModal_AWS`).modal('toggle');
$(`#ErrorModal_Unexpected`).modal('toggle');
return
}
// 予期せぬエラーが発生した場合
loading.stop();
$(`#modal_${ext}`).modal('toggle');
$(`#ErrorModal_Unexpected`).modal('toggle');
return
@ -425,29 +427,11 @@
%}
{% include '_modal.html' %}
{% endwith %}
<!-- AWS環境異常エラーモーダル -->
{% with
modal_id='ErrorModal_AWS',
modal_title='エラー',
message='AWS環境に異常が発生しました。管理者にお問い合わせください。',
icon_key='warning',
modal_close_event='location.href="/logout/?reason="',
buttons = [
{
'id': 'error_modal_aws',
'class': 'btn btn-primary',
'text': 'OK',
'onclick_event': 'location.href="/logout/?reason=''"'
}
]
%}
{% include '_modal.html' %}
{% endwith %}
<!-- DB接続失敗エラーモーダル -->
{% with
modal_id='ErrorModal_DB',
modal_title='エラー',
message='DB接続に失敗しました。管理者にお問い合わせください。',
message='DB接続に失敗しました。しばらく経ってから再度実行してください。',
icon_key='warning',
modal_close_event='location.href="/logout/?reason="',
buttons = [
@ -466,7 +450,7 @@
{% with
modal_id='ErrorModal_Unexpected',
modal_title='エラー',
message='サーバーエラーが発生しました。管理者にお問い合わせください。',
message='予期せぬエラーが発生しました。しばらく経ってから再度実行してください。',
icon_key='warning',
modal_close_event='location.href="/logout/?reason="',
buttons = [