Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

クライアント実行時のエラーメッセージを表示する #1

Open
e15d5605 opened this issue Aug 13, 2021 · 3 comments
Open

Comments

@e15d5605
Copy link
Collaborator

e15d5605 commented Aug 13, 2021

変換処理実行時にエラーメッセージが出力されていないため、原因を確認してメッセージが出力されるよう修正する

@e15d5605
Copy link
Collaborator Author

e15d5605 commented Aug 13, 2021

エラーメッセージ出力

以下のコマンドを実行するとエラーメッセージや利用方法を紹介するOptionsが出力される

 java -jar target/GlycanFormatConverter-cli.jar -i -e -seq
Missing argument for option: i

usage: glycanformatconverter --import <FORMAT> --export <FORMAT>
                             --sequence <Sequence>

Options:
 -e,--export
 <FORMAT=[IUPAC-Short|IUPAC-Condensed|IUPAC-Extended|GlycoCT|WURCS|GlycanW
 eb|JSON]>   export format.
 -h,--help
 Show usage help
 -i,--import
 <FORMAT=[IUPAC-Condensed|IUPAC-Extended|GlycoCT|KCF|LinearCode|WURCS|JSON
 ]>          import format.
 -seq,--sequence <SEQUENCE>
 Import glycan text format.
 -v,--version
 Print version information.

Version: 2.5.2

一方でデタラメなWURCSを入力するとエラーメッセージが得られない

 java -jar target/GlycanFormatConverter-cli.jar -i WURCS -e IUPAC-Extended -seq WURCS

@e15d5605
Copy link
Collaborator Author

各種変換処理のimporter/exporterは以下の関数で参照される

            portal.inputSequence(cli.getOptionValue(OPTION_SEQUENCE_LONG))
                    .inputFormat(InputFormat.forInputFormat(cli.getOptionValue(OPTION_IMPORT_LONG)))
                    .outputFormat(OutputFormat.forOutputFormat(cli.getOptionValue(OPTION_EXPORT_LONG)))
                    .start();

コンソールにメッセージを出力する場合はSystem.out.println()を使用する必要があり
start()ではe.getMessage()で例外時のエラーメッセージを取得しているだけだった

   public void start () {
        try {
            ...
        } catch (Exception e) {
            e.getMessage();
        }
    }

そのため、以下のように実装することでエラーメッセージが出力される

  public void start () {
        try {
            ...
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

@e15d5605
Copy link
Collaborator Author

e15d5605 commented Aug 13, 2021

動作確認

java -jar target/GlycanFormatConverter-cli.jar -i WURCS -e IUPAC-Extended -seq WURCS
An error in WURCS format.

正しくないWURCS入力したため、WURCSImporterの警告メッセージが返される\

java -jar target/GlycanFormatConverter-cli.jar -i WURCS -e IUPAC-Extended -seq WURCS=2.0/1,1,0/[a2122h-1x_1-6]/1/
GlycanFormatConverter can not handle this ring end : 6

対応することができない環情報を持つWURCSを入力した例

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant