Release version 1.1.5
[platform/core/appfw/appcore-widget.git] / src / widget_error.c
1 /*
2  * Copyright (c) 2015 - 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #include <string.h>
19 #include <libintl.h>
20
21 #include <dlog.h>
22 #include <widget_errno.h>
23
24 #include "widget-private.h"
25
26 #ifdef LOG_TAG
27 #undef LOG_TAG
28 #endif
29
30 #define LOG_TAG "CAPI_WIDGET_APPLICATION"
31
32 static const char *widget_app_error_to_string(widget_error_e error)
33 {
34         switch (error) {
35         case WIDGET_ERROR_NONE:
36                 return "NONE";
37         case WIDGET_ERROR_INVALID_PARAMETER:
38                 return "INVALID_PARAMETER";
39         case WIDGET_ERROR_OUT_OF_MEMORY:
40                 return "OUT_OF_MEMORY"; /* LCOV_EXCL_LINE */
41         case WIDGET_ERROR_RESOURCE_BUSY:
42                 return "RESOURCE_BUSY"; /* LCOV_EXCL_LINE */
43         case WIDGET_ERROR_PERMISSION_DENIED:
44                 return "PERMISSION_DENIED"; /* LCOV_EXCL_LINE */
45         case WIDGET_ERROR_CANCELED:
46                 return "CANCELED"; /* LCOV_EXCL_LINE */
47         case WIDGET_ERROR_IO_ERROR:
48                 return "IO_ERROR"; /* LCOV_EXCL_LINE */
49         case WIDGET_ERROR_TIMED_OUT:
50                 return "TIMED_OUT"; /* LCOV_EXCL_LINE */
51         case WIDGET_ERROR_NOT_SUPPORTED:
52                 return "NOT_SUPPORTED"; /* LCOV_EXCL_LINE */
53         case WIDGET_ERROR_FILE_NO_SPACE_ON_DEVICE:
54                 return "FILE_NO_SPACE_ON_DEVICE"; /* LCOV_EXCL_LINE */
55         case WIDGET_ERROR_FAULT:
56                 return "FAULT"; /* LCOV_EXCL_LINE */
57         case WIDGET_ERROR_ALREADY_EXIST:
58                 return "ALREADY_EXIST"; /* LCOV_EXCL_LINE */
59         case WIDGET_ERROR_ALREADY_STARTED:
60                 return "ALREADY_STARTED"; /* LCOV_EXCL_LINE */
61         case WIDGET_ERROR_NOT_EXIST:
62                 return "NOT_EXIST"; /* LCOV_EXCL_LINE */
63         case WIDGET_ERROR_DISABLED:
64                 return "DISABLED"; /* LCOV_EXCL_LINE */
65         default:
66                 return "UNKNOWN"; /* LCOV_EXCL_LINE */
67         }
68 }
69
70 int widget_app_error(widget_error_e error, const char *function,
71                 const char *description)
72 {
73         if (description) {
74                 LOGE("[%s] %s(0x%08x) : %s", function,
75                                 widget_app_error_to_string(error), error,
76                                 description);
77         } else {
78                 LOGE("[%s] %s(0x%08x)", function,
79                                 widget_app_error_to_string(error), error);
80         }
81
82         return error;
83 }
84