summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2012-05-23 21:35:39 +0200
committerLars-Dominik Braun <lars@6xq.net>2012-05-23 21:35:39 +0200
commit81bf363ac69e0036562434ca0e7153c3e624c8c3 (patch)
treecd1a21da84491f216e7466fdb11384989bdccf9b /src
parentdb4c66b2956a4da2745f16131fe573962c3fcbfb (diff)
downloadpianobar-81bf363ac69e0036562434ca0e7153c3e624c8c3.tar.gz
pianobar-81bf363ac69e0036562434ca0e7153c3e624c8c3.tar.bz2
pianobar-81bf363ac69e0036562434ca0e7153c3e624c8c3.zip
piano: Fix ambiguous error message/return value
Closes #263.
Diffstat (limited to 'src')
-rw-r--r--src/libpiano/piano.c4
-rw-r--r--src/libpiano/piano.h2
-rw-r--r--src/libpiano/response.c11
3 files changed, 17 insertions, 0 deletions
diff --git a/src/libpiano/piano.c b/src/libpiano/piano.c
index 9f4d7ec..47f2fa1 100644
--- a/src/libpiano/piano.c
+++ b/src/libpiano/piano.c
@@ -250,6 +250,10 @@ const char *PianoErrorToStr (PianoReturn_t ret) {
return "Out of memory.";
break;
+ case PIANO_RET_INVALID_LOGIN:
+ return "Wrong email address or password.";
+ break;
+
/* pandora error messages */
case PIANO_RET_P_INTERNAL:
return "Internal error.";
diff --git a/src/libpiano/piano.h b/src/libpiano/piano.h
index 249061b..ea21aa1 100644
--- a/src/libpiano/piano.h
+++ b/src/libpiano/piano.h
@@ -244,7 +244,9 @@ typedef enum {
PIANO_RET_INVALID_RESPONSE = 2,
PIANO_RET_CONTINUE_REQUEST = 3,
PIANO_RET_OUT_OF_MEMORY = 4,
+ PIANO_RET_INVALID_LOGIN = 5,
+ /* pandora error codes */
PIANO_RET_P_INTERNAL = PIANO_RET_OFFSET+0,
PIANO_RET_P_API_VERSION_NOT_SUPPORTED = PIANO_RET_OFFSET+11,
PIANO_RET_P_BIRTH_YEAR_INVALID = PIANO_RET_OFFSET+1025,
diff --git a/src/libpiano/response.c b/src/libpiano/response.c
index c3bfd6c..73b223a 100644
--- a/src/libpiano/response.c
+++ b/src/libpiano/response.c
@@ -100,6 +100,17 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) {
ret = PIANO_RET_INVALID_RESPONSE;
} else {
ret = json_object_get_int (code)+PIANO_RET_OFFSET;
+
+ if (ret == PIANO_RET_P_INVALID_PARTNER_LOGIN &&
+ req->type == PIANO_REQUEST_LOGIN) {
+ PianoRequestDataLogin_t *reqData = req->data;
+ if (reqData->step == 1) {
+ /* return value is ambiguous, as both, partnerLogin and
+ * userLogin return INVALID_PARTNER_LOGIN. Fix that to provide
+ * better error messages. */
+ ret = PIANO_RET_INVALID_LOGIN;
+ }
+ }
}
json_object_put (j);