create or replace package bsys.sys_error_api
is
-- 고정변수 정의
c_package_name constant varchar2(0200) default 'sys_error_api';
-- 함수 정의
function error_handler
(p_error in apex_error.t_error
) return apex_error.t_error_result;
end sys_error_api;
create or replace package body bsys.sys_error_api
/* ********************************************************************************************
* 업 무 단 위 : 시스템관리
* 패 키 지 : bsys.sys_error_api
* 사 용 목 적 : APEX 시스템 오류 메시지 제어 패키지
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
--------------------------------------------------------------------------------------------
* 수정일자 수정자 수정내역
--------------------------------------------------------------------------------------------
* 2024-02-01 Admin 최초 작성
******************************************************************************************** */
is
/* ********************************************************************************************
* 사 용 목 적 : 오류 메시지 교체 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
--gc_developer_todo_message constant varchar2(100) default 'DEVELOPER TODO: Provide better message in APEX Shared Components Text Messages for ';
function change_message
(p_constraint_name in varchar2
) return varchar2
is
pragma autonomous_transaction;
l_text_message varchar2(4000) default null; --:= gc_developer_todo_message || p_constraint_name;
begin
apex_lang.create_message
(p_application_id => v('APP_ID') -- 애플리케이션ID(7037800)
,p_name => p_constraint_name -- 테이블 유니크키 명치(COM_CODE_TYPE_UK)
,p_language => nvl(apex_util.get_preference('FSP_LANGUAGE_PREFERENCE'), 'en') -- 언어코드(en)
,p_message_text => l_text_message -- 텍스트 메시지(코드유형 데이터가 중복되었습니다.)
);
-- 저장
commit;
return l_text_message;
end change_message;
/* ********************************************************************************************
* 사 용 목 적 : APEX 오류 처리 핸드러 함수
* 생 성 일 자 : 2024-02-01
* 생 성 자 : Admin
******************************************************************************************** */
function error_handler
(p_error in apex_error.t_error
) return apex_error.t_error_result
is
l_result apex_error.t_error_result;
l_reference_id number default null;
l_constraint_name varchar2(255) default null;
--
l_result_cd number default null;
l_result_descr varchar2(4000) default null;
begin
l_result := apex_error.init_error_result(p_error);
-- 로그저장
sys_log_api.g_log := null;
sys_log_api.g_log.log_name := 'APEX 오류 처리 핸들러';
sys_log_api.g_log.param_package := 'bsys.sys_error_api.error_handler';
sys_log_api.g_log.corp_id := -1;
sys_log_api.g_log.param_corp_id := -1;
sys_log_api.g_log.param_lang_cd := upper(wwv_flow.g_flow_language);
sys_log_api.g_log.param_user_cd := upper(wwv_flow.g_user);
sys_log_api.g_log.param_transaction_type := 'V';
sys_log_api.g_log.param_file_name := null;
sys_log_api.g_log.param_info := '-- APEX 오류 처리 핸드러 변수값' || chr(10) ||
'message → ' || l_result.message || chr(10) ||
'additional_info → ' || l_result.additional_info || chr(10) ||
'display_location → ' || l_result.display_location || chr(10) ||
'page_item_name → ' || l_result.page_item_name || chr(10) ||
'column_alias → ' || l_result.column_alias;
sys_log_api.g_log.result_status_cd := 'U';
sys_log_api.g_log.result_descr := null;
sys_log_api.log_p(l_result_cd, l_result_descr);
if p_error.is_internal_error then
if not p_error.is_common_runtime_error then
l_result.message := '애플리케이션 오류가 발생하였습니다. 관리자에게 문의 바랍니다.(Reference ID : ' || l_reference_id || ')';
l_result.additional_info := null;
end if;
else
l_result.display_location := case when l_result.display_location = apex_error.c_on_error_page then apex_error.c_inline_in_notification
else l_result.display_location
end;
if p_error.ora_sqlcode in (-1, -2091, -2290, -2291, -2292) then
l_constraint_name := apex_error.extract_constraint_name(p_error);
l_result.message := apex_lang.message(l_constraint_name);
if l_result.message = l_constraint_name then
l_result.message := change_message (p_constraint_name => l_constraint_name);
end if;
end if;
if p_error.ora_sqlcode is not null and l_result.message = p_error.message then
l_result.message := apex_error.get_first_ora_error_text(p_error);
end if;
if l_result.page_item_name is null and l_result.column_alias is null then
apex_error.auto_set_associated_item(l_result, p_error);
end if;
end if;
-- 리턴
return l_result;
end error_handler;
end sys_error_api;
'오라클 > 패키지(시스템공통)' 카테고리의 다른 글
[ 권한 및 시노님 ] 시스템공통으로 사용할 패키지에 대한 권한 및 시노님을 부여합니다. (0) | 2024.04.12 |
---|---|
[ 로그생성 ] sys_log_api 패키지를 생성합니다. (0) | 2024.04.12 |
[ 환경설정 ] sys_env_api 패키지를 생성합니다. (0) | 2024.04.12 |
[ 업무코드 및 명칭조회 ] sys_get_api 패키지를 생성합니다. (0) | 2024.04.12 |
[ 세션정보 ] sys_env_f 함수를 생성합니다. (0) | 2024.04.12 |