[PR #566] [MERGED] fix: map authentication errors to a custom error type #971

Closed
opened 2026-02-27 20:00:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/566
Author: @xou816
Created: 1/18/2021
Status: Merged
Merged: 2/6/2021
Merged by: @sashahilton00

Base: devHead: fix/map-auth-errors


📝 Commits (1)

  • 71e9295 fix: map authentication errors to a custom error type

📊 Changes

4 files changed (+51 additions, -14 deletions)

View changed files

📝 core/src/authentication.rs (+35 -0)
📝 core/src/connection/mod.rs (+4 -6)
📝 core/src/session.rs (+9 -5)
📝 src/main.rs (+3 -3)

📄 Description

Fixes #565

Errors encountered during authenticate() are mapped to a custom error type with an ErrorKind enum (BadCredentials, PremiumAccountRequired, Io (wraps io errors) and Msg (generated, used as a default kind to keep unmapped errors readable)) instead of panicking.

I am not sure how backward compatibility is usually handled here however! I was thinking about adding this error mapping to a new Session::try_connect (not sure about the naming) function, while keeping the same behavior for Session::connect


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/librespot-org/librespot/pull/566 **Author:** [@xou816](https://github.com/xou816) **Created:** 1/18/2021 **Status:** ✅ Merged **Merged:** 2/6/2021 **Merged by:** [@sashahilton00](https://github.com/sashahilton00) **Base:** `dev` ← **Head:** `fix/map-auth-errors` --- ### 📝 Commits (1) - [`71e9295`](https://github.com/librespot-org/librespot/commit/71e9295ee8cc9c9acd8345fc5d0ffe192c55fdff) fix: map authentication errors to a custom error type ### 📊 Changes **4 files changed** (+51 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `core/src/authentication.rs` (+35 -0) 📝 `core/src/connection/mod.rs` (+4 -6) 📝 `core/src/session.rs` (+9 -5) 📝 `src/main.rs` (+3 -3) </details> ### 📄 Description Fixes #565 Errors encountered during authenticate() are mapped to a custom error type with an ErrorKind enum (`BadCredentials`, `PremiumAccountRequired`, `Io` (wraps io errors) and `Msg` (generated, used as a default kind to keep unmapped errors readable)) instead of panicking. I am not sure how backward compatibility is usually handled here however! I was thinking about adding this error mapping to a new Session::try_connect (not sure about the naming) function, while keeping the same behavior for Session::connect --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:00:39 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#971
No description provided.