From: Minje Ahn Date: Thu, 6 Feb 2020 05:40:49 +0000 (+0900) Subject: Improve error type conversion function X-Git-Tag: accepted/tizen/unified/20200207.122428^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F67%2F224067%2F4;p=platform%2Fcore%2Fapi%2Fmedia-content.git Improve error type conversion function Change-Id: Ic58549ff048229ea94b59f4da83711d330e33e88 Signed-off-by: Minje Ahn --- diff --git a/include/media_info_private.h b/include/media_info_private.h index e7e8cb2..fd12faa 100755 --- a/include/media_info_private.h +++ b/include/media_info_private.h @@ -525,7 +525,7 @@ typedef struct _media_content_cb_data { int _content_query_prepare(char *select_query, char *condition_query, char *option_query, sqlite3_stmt **stmt); int _content_get_result(char *query, sqlite3_stmt **stmt); -int _content_error_capi(int content_error); +int _content_error_capi(int internal_error); int _content_query_sql(char *query_str); sqlite3 * _content_get_db_handle(void); uid_t _content_get_uid(void); diff --git a/include_product/media_info_private.h b/include_product/media_info_private.h index 28d757d..e25cb0d 100755 --- a/include_product/media_info_private.h +++ b/include_product/media_info_private.h @@ -739,7 +739,7 @@ typedef struct _media_content_scan_cb_data_v2 { int _content_query_prepare(char *select_query, char *condition_query, char *option_query, sqlite3_stmt **stmt); int _content_get_result(char *query, sqlite3_stmt **stmt); -int _content_error_capi(int content_error); +int _content_error_capi(int internal_error); int _content_query_sql(char *query_str); sqlite3 * _content_get_db_handle(void); uid_t _content_get_uid(void); diff --git a/src/media_content.c b/src/media_content.c index 15739a3..1e5c894 100644 --- a/src/media_content.c +++ b/src/media_content.c @@ -136,43 +136,37 @@ int _content_query_prepare_by_union_select(sqlite3_stmt **stmt, char *select_que } #endif -int _content_error_capi(int content_error) +int _content_error_capi(int internal_error) { - if (content_error != MEDIA_CONTENT_ERROR_NONE) - media_content_error("MS Error[%d]", content_error); - - /*Error None*/ - if (content_error == MS_MEDIA_ERR_NONE) + if (internal_error == MS_MEDIA_ERR_NONE) return MEDIA_CONTENT_ERROR_NONE; - /* Internal operation error*/ - else if (content_error == MS_MEDIA_ERR_INVALID_PARAMETER) - return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + media_content_error("MS Error[%d]", internal_error); - else if (content_error == MS_MEDIA_ERR_OUT_OF_MEMORY) + switch (internal_error) { + case MS_MEDIA_ERR_INVALID_PARAMETER: + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + case MS_MEDIA_ERR_OUT_OF_MEMORY: return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - - /* DB operation error*/ - else if (content_error == MS_MEDIA_ERR_DB_BUSY_FAIL) + case MS_MEDIA_ERR_DB_BUSY_FAIL: return MEDIA_CONTENT_ERROR_DB_BUSY; - - else if ((content_error <= MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) && (content_error >= MS_MEDIA_ERR_DB_INTERNAL)) + case MS_MEDIA_ERR_DB_CONSTRAINT_FAIL: + case MS_MEDIA_ERR_DB_NO_RECORD: + case MS_MEDIA_ERR_DB_CORRUPT: + case MS_MEDIA_ERR_DB_FULL_FAIL: + case MS_MEDIA_ERR_DB_RESET: + case MS_MEDIA_ERR_DB_INTERNAL: return MEDIA_CONTENT_ERROR_DB_FAILED; - - /* IPC operation error*/ - else if (content_error == MS_MEDIA_ERR_IPC) + case MS_MEDIA_ERR_IPC: return MEDIA_CONTENT_ERROR_NETWORK; - - /* MEDIA SERVER error*/ - else if (content_error == MS_MEDIA_ERR_PERMISSION_DENIED) + case MS_MEDIA_ERR_PERMISSION_DENIED: return MEDIA_CONTENT_ERROR_PERMISSION_DENIED; - - /* Thumbnail error*/ - else if ((content_error == MS_MEDIA_ERR_THUMB_TOO_BIG) || (content_error == MS_MEDIA_ERR_THUMB_UNSUPPORTED)) - return MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT; - - /*ETC*/ - return MEDIA_CONTENT_ERROR_INVALID_OPERATION; + case MS_MEDIA_ERR_THUMB_TOO_BIG: + case MS_MEDIA_ERR_THUMB_UNSUPPORTED: + return MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT; + default: + return MEDIA_CONTENT_ERROR_INVALID_OPERATION; + } } int _content_query_sql(char *query_str)