summaryrefslogtreecommitdiff
path: root/libpiano/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-23 19:30:51 +0200
committerLars-Dominik Braun <PromyLOPh@gmail.com>2008-07-23 19:30:51 +0200
commit75788c6d832e79b6e20115062f77afd5cd959a3d (patch)
tree32e8c36e14e54c19668efbd8e2a35e7f48c277ec /libpiano/src
parent5afcd41752602f8c76faab8042a46e6b8c66bbb6 (diff)
downloadpianobar-75788c6d832e79b6e20115062f77afd5cd959a3d.tar.gz
pianobar-75788c6d832e79b6e20115062f77afd5cd959a3d.tar.bz2
pianobar-75788c6d832e79b6e20115062f77afd5cd959a3d.zip
piano: Human-readable error messages
Diffstat (limited to 'libpiano/src')
-rw-r--r--libpiano/src/main.c36
-rw-r--r--libpiano/src/piano.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/libpiano/src/main.c b/libpiano/src/main.c
index 7215fae..7887132 100644
--- a/libpiano/src/main.c
+++ b/libpiano/src/main.c
@@ -778,3 +778,39 @@ PianoReturn_t PianoTransformShared (PianoHandle_t *ph,
return ret;
}
+
+/* convert return value to human-readable string
+ * @param enum
+ * @return error string
+ */
+const char *PianoErrorToStr (PianoReturn_t ret) {
+ switch (ret) {
+ case PIANO_RET_OK:
+ return "Everything is fine :)";
+ break;
+
+ case PIANO_RET_ERR:
+ return "Unknown.";
+ break;
+
+ case PIANO_RET_XML_INVALID:
+ return "Invalid XML.";
+ break;
+
+ case PIANO_RET_AUTH_TOKEN_INVALID:
+ return "Invalid auth token.";
+ break;
+
+ case PIANO_RET_AUTH_USER_PASSWORD_INVALID:
+ return "Username and/or password not correct.";
+ break;
+
+ case PIANO_RET_NET_ERROR:
+ return "Connection failed.";
+ break;
+
+ default:
+ return "No error message available.";
+ break;
+ }
+}
diff --git a/libpiano/src/piano.h b/libpiano/src/piano.h
index 0850517..ed3014a 100644
--- a/libpiano/src/piano.h
+++ b/libpiano/src/piano.h
@@ -186,5 +186,6 @@ PianoStation_t *PianoFindStationById (PianoStation_t *stations,
PianoReturn_t PianoGetGenreStations (PianoHandle_t *ph);
PianoReturn_t PianoTransformShared (PianoHandle_t *ph,
PianoStation_t *station);
+const char *PianoErrorToStr (PianoReturn_t ret);
#endif /* _PIANO_H */