author | Mario Ferraro <fadinlight@gmail.com> |
Sun, 15 Nov 2009 22:12:20 +0100 | |
changeset 3093 | d1be59b6b627 |
parent 2614 | dbc8a50dbce0 |
permissions | -rw-r--r-- |
2614
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Module for handling errors while running a Task. |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
] |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
import logging |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
27 |
from django import http |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
28 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
29 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
30 |
def logErrorAndReturnOK(error_msg='Error found in Task'): |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
"""Logs the given error message and returns a HTTP OK response. |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
32 |
|
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
Args: |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
34 |
error_msg: Error message to log |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
35 |
""" |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
36 |
logging.error(error_msg) |
dbc8a50dbce0
Refactored logErrorAndReturnOK into separate module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
return http.HttpResponse() |