package com.estiuka.dev.fmydroid.control;
import com.estiuka.dev.fmydroid.R;
/**
* class to manage the errors in FMyDroid
*
* @author kelykos
*
*/
public class FMDError {
// generic errors
public static final int NO_ERROR = 0;
public static final int NOT_FOUND_ERROR = 1;
public static final int GENERAL_ERROR = 2;
public static final int BUSY_ERROR = 3;
// Network errors
public static final int NO_NETWORK_ERROR = 10;
// communication
public static final int TIMEOUT_ERROR = 20;
public static final int CONNECTION_ERROR = 21;
// parsing error
public static final int INVALID_XML_ERROR = 30;
public static final int PARSER_CONFIG_ERROR = 31;
// FMyLife error
public static final int NO_CATEGORY_ERROR = 40;
public static final int NO_STORY_LIST_ERROR = 41;
public static final int NO_STORY_ERROR = 42;
public static final int NO_COMMENTS_ERROR = 43;
public static final int INVALID_DETAILS_ERROR = 44;
public static final int SUBMIT_VOTE_ERROR = 45;
public static final int SUBMIT_STORY_ERROR = 46;
public static final int SUBMIT_COMMENT_ERROR = 47;
public static final int MODERATE_STORY_ERROR = 48;
public static final int LOGIN_ERROR = 49;
public static final int LOGOUT_ERROR = 50;
public static final int REQUEST_ERROR = 51;
public static final int MODERATE_STORYLIST_ERROR = 52;
public static final int SUBMIT_MODERATION_ERROR = 53;
public static final int UNKNOWN_CATEGORY_ERROR = 54;
public static final int NO_STORY_TO_MODERATE_ERROR = 55;
// ADD FAVORITES ERROR
public static final int ADD_FAVORITES_ALREADY_ADDED = 70;
public static final int ADD_FAVORITES_ALREADY_DELETED = 71;
/**
* static method to rretrieve the error message associated to
* the given error code
* @param errorCode
* @return android string id of the associated error message
*/
public static int GetErrorString(int errorCode) {
switch (errorCode) {
case NO_ERROR:
return android.R.string.ok;
case NOT_FOUND_ERROR:
return R.string.error_not_found;
case GENERAL_ERROR:
return R.string.error_general;
case BUSY_ERROR:
return R.string.error_busy;
case NO_NETWORK_ERROR:
return R.string.error_no_connectivity;
case TIMEOUT_ERROR:
return R.string.error_timeout;
case CONNECTION_ERROR:
return R.string.error_no_connection;
case INVALID_XML_ERROR:
return R.string.error_invalid_xml;
case PARSER_CONFIG_ERROR:
return R.string.error_parser_config;
case NO_CATEGORY_ERROR:
return R.string.categories_unavailable;
case UNKNOWN_CATEGORY_ERROR:
return R.string.categories_unknown;
case NO_STORY_LIST_ERROR:
return R.string.no_stories_found;
case NO_STORY_ERROR:
return R.string.story_unavailable;
case NO_COMMENTS_ERROR:
return R.string.no_comments_found;
case INVALID_DETAILS_ERROR:
return R.string.error_login_invalid_usr_or_pwd;
case SUBMIT_VOTE_ERROR:
case SUBMIT_STORY_ERROR:
case SUBMIT_COMMENT_ERROR:
return R.string.error_submission_general;
case SUBMIT_MODERATION_ERROR:
return R.string.error_when_submitting_your_moderation;
case MODERATE_STORY_ERROR:
case MODERATE_STORYLIST_ERROR:
return R.string.error_moderation_data;
case NO_STORY_TO_MODERATE_ERROR:
return R.string.no_more_story_to_moderate;
case LOGIN_ERROR:
return R.string.error_login_general;
case LOGOUT_ERROR:
return R.string.error_logout_general;
case REQUEST_ERROR:
return R.string.error_invalid_request;
case ADD_FAVORITES_ALREADY_ADDED:
return R.string.error_already_favourite;
case ADD_FAVORITES_ALREADY_DELETED:
return R.string.error_nomore_favourite;
}
return R.string.error_general;
}
}
|