use class_name for instance id
[platform/core/appfw/appcore-widget.git] / src / widget_error.c
1 /*
2  * Copyright (c) 2015 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
38         case WIDGET_ERROR_INVALID_PARAMETER:
39                 return "INVALID_PARAMETER";
40
41         case WIDGET_ERROR_OUT_OF_MEMORY:
42                 return "OUT_OF_MEMORY";
43
44         case WIDGET_ERROR_RESOURCE_BUSY:
45                 return "RESOURCE_BUSY";
46
47         case WIDGET_ERROR_PERMISSION_DENIED:
48                 return "PERMISSION_DENIED";
49
50         case WIDGET_ERROR_CANCELED:
51                 return "CANCELED";
52
53         case WIDGET_ERROR_IO_ERROR:
54                 return "IO_ERROR";
55
56         case WIDGET_ERROR_TIMED_OUT:
57                 return "TIMED_OUT";
58
59         case WIDGET_ERROR_NOT_SUPPORTED:
60                 return "NOT_SUPPORTED";
61
62         case WIDGET_ERROR_FILE_NO_SPACE_ON_DEVICE:
63                 return "FILE_NO_SPACE_ON_DEVICE";
64
65         case WIDGET_ERROR_FAULT:
66                 return "FAULT";
67
68         case WIDGET_ERROR_ALREADY_EXIST:
69                 return "ALREADY_EXIST";
70
71         case WIDGET_ERROR_ALREADY_STARTED:
72                 return "ALREADY_STARTED";
73
74         case WIDGET_ERROR_NOT_EXIST:
75                 return "NOT_EXIST";
76
77         case WIDGET_ERROR_DISABLED:
78                 return "DISABLED";
79
80         default:
81                 return "UNKNOWN";
82         }
83 }
84
85 int widget_app_error(widget_error_e error, const char* function,
86                         const char *description)
87 {
88         if (description) {
89                 LOGE("[%s] %s(0x%08x) : %s", function, widget_app_error_to_string(error), error,
90                      description);
91         } else {
92                 LOGE("[%s] %s(0x%08x)", function, widget_app_error_to_string(error), error);
93         }
94
95         return error;
96 }