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