Fix the widget_app_get_id()
[platform/core/appfw/appcore-widget.git] / src / widget_error.c
1 /*
2  * Copyright (c) 2015 - 2016 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_APPLICATIO"
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";
41         case WIDGET_ERROR_RESOURCE_BUSY:
42                 return "RESOURCE_BUSY";
43         case WIDGET_ERROR_PERMISSION_DENIED:
44                 return "PERMISSION_DENIED";
45         case WIDGET_ERROR_CANCELED:
46                 return "CANCELED";
47         case WIDGET_ERROR_IO_ERROR:
48                 return "IO_ERROR";
49         case WIDGET_ERROR_TIMED_OUT:
50                 return "TIMED_OUT";
51         case WIDGET_ERROR_NOT_SUPPORTED:
52                 return "NOT_SUPPORTED";
53         case WIDGET_ERROR_FILE_NO_SPACE_ON_DEVICE:
54                 return "FILE_NO_SPACE_ON_DEVICE";
55         case WIDGET_ERROR_FAULT:
56                 return "FAULT";
57         case WIDGET_ERROR_ALREADY_EXIST:
58                 return "ALREADY_EXIST";
59         case WIDGET_ERROR_ALREADY_STARTED:
60                 return "ALREADY_STARTED";
61         case WIDGET_ERROR_NOT_EXIST:
62                 return "NOT_EXIST";
63         case WIDGET_ERROR_DISABLED:
64                 return "DISABLED";
65         default:
66                 return "UNKNOWN";
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