2012-06-12 4 views
0

alfresco 워크 플로 예외에 대한 내 메시지 만 표시하려고합니다. 그러나 야외에서 예외 메시지 형식은 그 1. exception.class.name 2. ErrorLogNumber 3. 메시지 예를 들어Alfresco 예외 메시지 형식

, org.alfresco.service.cmr.workflow.WorkflowException : 05130007 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

오직 1.exception.class.name 및 2.ErrorLogNumber가 아닌 3.Message를 보여주고 싶습니다. 사용자 정의 예외 클래스를 추가하여 Message에서 ErrorLogNumber를 제거 할 수 있습니다. 하지만 오류 메시지에서 1.exception.class.name을 제거 할 수는 없습니다. 구현 방법을 알려주십시오.

+0

예외에서'toString()'을 호출하는 대신'getMessage()'를 사용하여 메시지를 꺼내려고 했습니까? – Gagravarr

답변

0

예외 클래스에서 toString을 재정의하려 했습니까? 출력이 이렇게 인쇄되면 로거 구현을 변경하십시오.

0

나는 당신과 비슷한 문제가있어서 디버거를 사용해도이 메시지가 어디서 생성되었는지를 추적하지 못했습니다. 아주 까다 롭습니다. 또한 Alfresco 포럼에있는 누구라도 나를 도울 수 없습니다. 자바 워크 플로우 태스크에서 직접 예외를 던지는 대신 임시 해결책을 개발했습니다. 폼에서 JS 유효성 검사 (다른 포스트에서 말한 방식)를 사용했습니다. 거기에 JS 오류를 표시하는 ajax를 사용하여 자바 웹 스크립트를 호출했습니다. 경고 상자.

1

해결책은 간단합니다. 메시지를 AlfrescoRuntimeException에게 보내십시오.

throw new AlfrescoRuntimeException("your.message"); 

그런 경우 메시지가 표시되지만 느슨한 예외 하위 유형이 있습니다.

은 야외 자바 스크립트 코드에서 예외 처리를봤을 때 내가 놀랐어 어떻게 말로 설명하기가 정말 어렵습니다 :

 onFormSubmitFailure: function FormManager_onFormSubmitFailure(response) 
     { 
      var failureMsg = null; 
      if (response.json && response.json.message && response.json.message.indexOf("Failed to persist field 'prop_cm_name'") !== -1) 
      { 
       failureMsg = this.msg("message.details.failure.name"); 
      } 
      else if (response.json && response.json.message && response.json.message.indexOf("PropertyValueSizeIsMoreMaxLengthException") !== -1) 
      { 
       failureMsg = this.msg("message.details.failure.more.max.length"); 
      } 
      else if (response.json && response.json.message && response.json.message.indexOf("org.alfresco.error.AlfrescoRuntimeException") == 0) 
      { 
       var split = response.json.message.split(/(?:org.alfresco.error.AlfrescoRuntimeException:\s*\d*\s*)/ig); 
       if (split && split[1]) 
       { 
        failureMsg = split[1]; 
       } 
      } 
      Alfresco.util.PopupManager.displayPrompt(
      { 
       title: this.msg(this.options.failureMessageKey), 
       text: failureMsg ? failureMsg : (response.json && response.json.message ? response.json.message : this.msg("message.details.failure")) 
      }); 
     }, 

당신이 자바에서 그들은 "캐치"클래스 이름을보고 메시지로 대체 할 수있다. 고객의 예외 사항을 처리 할 수있는보다 확장 가능한 방법을 제공하기를 바랍니다.

P. 물론 또 다른 방법은 alfresco.js 파일을 확장하고 하나 더 if else 조건을 예외로 추가하는 것입니다.