Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #3891 - use a swtich because this way clang will issue a wa…
Browse files Browse the repository at this point in the history
…rning if a new `Reason` is added without updating this code
  • Loading branch information
zugaldia committed Feb 25, 2016
1 parent 1b12ee1 commit 796a082
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions platform/android/src/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1950,21 +1950,24 @@ void JNICALL setOfflineRegionObserver(JNIEnv *env, jobject obj, jobject offlineR
JNIEnv* env2;
jboolean renderDetach = attach_jni_thread(theJVM, &env2, "Offline Thread");

// Choose a value for error.reason independent of the underlying int value
// Handle the value of reason independently of the underlying int value
std::string errorReason;
if (error.reason == mbgl::Response::Error::Reason::Success) {
errorReason = "REASON_SUCCESS";
} else if (error.reason == mbgl::Response::Error::Reason::NotFound) {
errorReason = "REASON_NOT_FOUND";
} else if (error.reason == mbgl::Response::Error::Reason::Server) {
errorReason = "REASON_SERVER";
} else if (error.reason == mbgl::Response::Error::Reason::Connection) {
errorReason = "REASON_CONNECTION";
} else if (error.reason == mbgl::Response::Error::Reason::Other) {
errorReason = "REASON_OTHER";
} else {
mbgl::Log::Error(mbgl::Event::JNI, "Unsupported Response::Error::Reason value.");
return;
switch(error.reason) {
case mbgl::Response::Error::Reason::Success:
errorReason = "REASON_SUCCESS";
break;
case mbgl::Response::Error::Reason::NotFound:
errorReason = "REASON_NOT_FOUND";
break;
case mbgl::Response::Error::Reason::Server:
errorReason = "REASON_SERVER";
break;
case mbgl::Response::Error::Reason::Connection:
errorReason = "REASON_CONNECTION";
break;
case mbgl::Response::Error::Reason::Other:
errorReason = "REASON_OTHER";
break;
}

// Error object
Expand Down

0 comments on commit 796a082

Please sign in to comment.