VOICEVOX / voicevox_core

無料で使える中品質なテキスト読み上げソフトウェア、VOICEVOXのコア
https://voicevox.hiroshiba.jp/
MIT License
866 stars 117 forks source link

Python APIとJava APIのエラーを詳細にする #640

Closed qryxip closed 1 year ago

qryxip commented 1 year ago

内容

Python APIとJava APIの例外に、次の変更を加えます。

  1. VoicevoxError/VoicevoxExceptionを解体し、細分化

    以下の例外クラスを継承するようにする。

    Python Java
    NotLoadedOpenjtalkDict Exception IllegalStateException
    GpuSupport Exception RuntimeException
    OpenZipFile Exception IOException
    ReadZipEntry Exception IOException
    ModelAlreadyLoaded Exception IllegalStateException
    StyleAlreadyLoaded Exception IllegalStateException
    InvalidModelData Exception IOException
    GetSupportedDevices Exception IOException
    StyleNotFound KeyError IndexOutOfBoundsException
    ModelNotFound KeyError IndexOutOfBoundsException
    InferenceFailed Exception IOException
    ExtractFullContextLabel Exception IllegalArgumentException
    ParseKana ValueError IllegalArgumentException
    LoadUserDict Exception IOException
    SaveUserDict Exception IOException
    WordNotFound KeyError IndexOutOfBoundsException
    UseUserDict Exception RuntimeException
    InvalidWord ValueError IllegalArgumentException
    その他 ValueErrorとか IllegalArgumentExceptionとか
  2. Rustの"source"を"cause"に反映

    Exception: なんかのエラー (1)
    
    The above exception was the direct cause of the following exception:
    
    Exception: なんかのエラー (2)
    
    The above exception was the direct cause of the following exception:
    
    Exception: unable to locate the end of central directory record
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "./run.py", line 104, in <module>
        asyncio.run(main())
      File "/home/ryo/.pyenv/versions/3.8.15/lib/python3.8/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/home/ryo/.pyenv/versions/3.8.15/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
        return future.result()
      File "./run.py", line 46, in main
        model = await VoiceModel.from_path(vvm_path)
    voicevox_core.OpenZipFileError: `/dev/null`の読み込みに失敗しました: ZIPファイルとして開くことができませんでした

関連 Issue

580, #589, #600, #622, #623, #624 の続きです。

ref #545

その他

580 で言ったこれに対応します。

  • Python APIとJava APIでsourceの内容を表現
qryxip commented 1 year ago

コードが整っているとは言えない状態ですが、とりあえず実装は完了。

qryxip commented 1 year ago

今気付いたのですがJava APIの方、IOException相当のものをthrowするならthrowsにしないと駄目ですね。多分。

qryxip commented 1 year ago

今気付いたのですがJava APIの方、IOException相当のものをthrowするならthrowsにしないと駄目ですね。多分。

これを今やりました。 9e87842 (#640)

@sevenc-nanashi すみません。お手数ですがこちらも確認して頂いてもよいでしょうか。OKならそのままマージして頂けると。

sevenc-nanashi commented 1 year ago

CI通ったらマージします。