|
| 1 | +""" |
| 2 | + * MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2012 - 2019 Contentstack |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all |
| 14 | + * copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + * SOFTWARE. |
| 23 | + * |
| 24 | +""" |
| 25 | + |
| 26 | + |
| 27 | +import logging |
| 28 | + |
| 29 | +class HTTPError(Exception): |
| 30 | + |
| 31 | + errors_str = { |
| 32 | + |
| 33 | + 'error_invalid_json' : "Please provide valid JSON.", |
| 34 | + 'error_message_stack_api_key_is_null' : "Stack api key can not be null.", |
| 35 | + 'error_form_name' : "Please set contentType name.", |
| 36 | + 'error_stack_access_token_is_null' : "Access token can not be null.", |
| 37 | + 'error_stack_environment_is_null' : "Environment can not be null.", |
| 38 | + 'Error_Connection_Error' : "Connection error", |
| 39 | + 'Error_Auth_Failure_Error' : "Authentication Not present.", |
| 40 | + 'Error_Parse_Error' : "Parsing Error.", |
| 41 | + 'Error_Server_Error' : "Server interaction went wrong, Please try again.", |
| 42 | + 'Error_Default' : "Oops! Something went wrong. Please try again.", |
| 43 | + 'Error_No_Network' : "Network not available.", |
| 44 | + 'Error_Called_Default_Method' : "You must called Contentstack.stack() first", |
| 45 | + 'Error_Query_Filter_Exception' : "Please provide valid params." |
| 46 | + } |
| 47 | + |
| 48 | +def __init__(self): |
| 49 | + |
| 50 | + errors = { |
| 51 | + |
| 52 | + 400: "The request was incorrect or corrupted.", |
| 53 | + 401: "The login credentials are invalid.", |
| 54 | + 403: "The page or resource that is being accessed is forbidden.", |
| 55 | + 404: "The requested page or resource could not be found.", |
| 56 | + 412: "The entered API key is invalid.", |
| 57 | + 422: "The request is syntactically correct but contains semantic errors", |
| 58 | + 429: "The number of requests exceeds the allowed limit for the given time period.", |
| 59 | + 500: "The server is malfunctioning and is not specific on what the problem is.", |
| 60 | + 502: "A server received an invalid response from another server.", |
| 61 | + 504: "A server did not receive a timely response from another server that it was accessing while attempting to load the web page or fill another request by the browser." |
| 62 | + } |
| 63 | + |
| 64 | + |
| 65 | + def get_error(self, response): |
| 66 | + print('Error') |
| 67 | + |
| 68 | + |
| 69 | + def set_logging_config(self,level): |
| 70 | + print('level '+level) |
| 71 | + |
| 72 | + |
| 73 | +class ConfigError(Exception): |
| 74 | + """Configuration Error Class""" |
| 75 | + pass |
| 76 | + |
| 77 | + |
0 commit comments