Skip to content

refactor: エラー型の粒度を細分化する - #48

Merged
hitalin merged 2 commits into
developfrom
refactor/error-granularity
Aug 2, 2026
Merged

refactor: エラー型の粒度を細分化する#48
hitalin merged 2 commits into
developfrom
refactor/error-granularity

Conversation

@hitalin

@hitalin hitalin commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

なぜ

Auth(String)code() が一律 "AUTH" になるため、消費者は「再ログインが要る」のか「MiAuth をやり直す」のかを判別できなかった。またサーバーが返す error.codeApimessage に埋め込まれるだけで、消費側 (notedeck) が正規表現でメッセージから復元していた。

変更

  • Auth(String)Auth(AuthErrorKind)NoToken / MiAuthFailed(status) / MiAuthPending / MiAuthMalformed / SessionInvalid / CredentialMissing に分け、code()AUTH_ 接頭辞付きで variant ごとに分かれる
  • Apiapi_code: Option<String> を追加し、serialize に apiCode として出す。request() はサーバー由来の error.code をそのまま載せる
  • WebSocket(String) を削除(生成箇所がゼロの死んだ variant。streaming は ConnectionClosed / NoConnection / InvalidInput を使っている)
  • Internal(String) を追加。認証と無関係な内部不整合の受け皿とし、safe_message() では詳細を伏せる

確認

  • cargo test 200 passed
  • cargo clippy --all-targets --all-features -- -D warnings / --no-default-features ともに警告なし

ref: notedeck#327

🤖 Generated with Claude Code

hitalin and others added 2 commits August 1, 2026 09:10
文字列ベースの Auth(String) は code が一律 "AUTH" になり、呼び出し側が
回復手段を選べなかった。また Misskey が返す error.code は Api の message
に埋め込まれるだけで、消費者側が文字列を parse して復元していた。

- Auth(String) → Auth(AuthErrorKind): NoToken / MiAuthFailed / MiAuthPending
  / MiAuthMalformed / SessionInvalid / CredentialMissing。code() は
  AUTH_ 接頭辞付きで variant ごとに分かれる
- Api に api_code: Option<String> を追加し、serialize に apiCode として出す。
  request() はサーバー由来の error.code をそのまま載せる
- WebSocket(String) を削除(生成箇所がゼロの死んだ variant)
- Internal(String) を追加。認証と無関係な内部不整合の受け皿とし、
  safe_message() では詳細を伏せる

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cb4ea185-b04e-4311-84f2-bc94e412870f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@hitalin hitalin self-assigned this Aug 2, 2026
@hitalin
hitalin merged commit 664ceee into develop Aug 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant