tizen 2.3 release
[framework/api/application.git] / app_common / app_error.c
1 /*
2  * Copyright (c) 2011 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 <dlog.h>
19
20 #include <app.h>
21
22 #ifdef LOG_TAG
23 #undef LOG_TAG
24 #endif
25
26 #define LOG_TAG "CAPI_APPFW_APPLICATION"
27
28 static const char* app_error_to_string(app_error_e error)
29 {
30         switch (error)
31         {
32         case APP_ERROR_NONE:
33                 return "NONE";
34
35         case APP_ERROR_INVALID_PARAMETER:
36                 return "INVALID_PARAMETER";
37
38         case APP_ERROR_OUT_OF_MEMORY:
39                 return "OUT_OF_MEMORY";
40
41         case APP_ERROR_INVALID_CONTEXT:
42                 return "INVALID_CONTEXT";
43
44         case APP_ERROR_NO_SUCH_FILE:
45                 return "NO_SUCH_FILE";
46
47         case APP_ERROR_ALREADY_RUNNING:
48                 return "ALREADY_RUNNING";
49
50         default :
51                 return "UNKNOWN";
52         }
53 }
54
55 int app_error(app_error_e error, const char* function, const char *description)
56 {
57         if (description)
58         {
59                 LOGE("[%s] %s(0x%08x) : %s", function, app_error_to_string(error), error, description);
60         }
61         else
62         {
63                 LOGE("[%s] %s(0x%08x)", function, app_error_to_string(error), error);
64         }
65
66         return error;
67 }