0

Alfresco ワークフロー例外のメッセージのみを表示したい。ただし、屋外の例外メッセージの形式は、1.exception.class.name 2.ErrorLogNumber 3.Message です

たとえば、 org.alfresco.service.cmr.workflow.WorkflowException: 05130007 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

1.exception.class.name と 2.ErrorLogNumber ではなく 3.Message のみを表示したい。カスタム例外クラスを追加することで、メッセージから ErrorLogNumber を削除できます。しかし、エラー メッセージから 1.exception.class.name を削除できません。それを実装する方法を教えてください。

4

3 に答える 3

1

解決策は非常に簡単です。AlfrescoRuntimeExceptionメッセージを添えて投げるだけ。

throw new AlfrescoRuntimeException("your.message");

その場合、メッセージが表示されますが、例外のサブタイプが失われます。

屋外の javaScript コードで例外処理を見たときの驚きを言葉で説明するのは非常に困難です。

        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"))
           });
        },

ご覧のとおり、Java からクラス名を「キャッチ」し、それをメッセージに置き換えます。カスタム例外を処理するためのより拡張可能な方法を提供してくれることを願っています。

PSもちろん、別の方法は、ファイルを拡張して、例外の条件をalfresco.jsもう1つ追加することです。if else

于 2016-11-17T06:07:57.920 に答える
0

例外クラスで toString をオーバーライドしようとしましたか? または、出力がこの方法で出力される場合は、ロガーの実装を変更することもできます。

于 2012-06-14T12:45:23.623 に答える
0

あなたと同様の問題があり、デバッガーを使用してもこのメッセージが作成された場所を追跡できませんでした。また、Alfresco フォーラムの誰も私を助けてくれませんでした。Javaワークフロータスクで直接例外をスローする代わりに回避策を開発し、フォームでJS検証を使用しました(別の投稿で説明した方法)。そこで、ajaxを使用してJava Webscriptを呼び出しました。エラーが発生した場合、JSアラートが表示されました箱。

于 2012-07-10T13:38:32.953 に答える