1# -------------------------------------------------------------------------------------------- 2# Copyright (c) Microsoft Corporation. All rights reserved. 3# Licensed under the MIT License. See License.txt in the project root for license information. 4# -------------------------------------------------------------------------------------------- 5 6# pylint: disable=line-too-long 7 8 9class ErrorClass: 10 error_title = "" 11 error_message = "" 12 13 def __init__(self, title, message): 14 self.error_title = title 15 self.error_message = message 16 17 def get_error_message(self, additional_message=None): 18 if additional_message: 19 return "An error occurred: {}\n{}\n{}".format(self.error_title, self.error_message, additional_message) 20 21 return "An error occurred: {}\n{}".format(self.error_title, self.error_message) 22 23 def set_error_message(self, message): 24 return ErrorClass(self.error_title, message) 25 26 def append_error_message(self, message): 27 return self.set_error_message(self.error_message + "\n" + message) 28 29 def format_error_message(self, *args): 30 return self.set_error_message(self.error_message.format(*args)) 31 32 33# DOCKER ERRORS 34DOCKER_COMMAND_ERROR = ErrorClass( 35 "DOCKER_COMMAND_ERROR", 36 "Please verify if Docker client is installed and running." 37) 38 39 40DOCKER_DAEMON_ERROR = ErrorClass( 41 "DOCKER_DAEMON_ERROR", 42 "Please verify if Docker daemon is running, or try restarting it." 43) 44 45 46DOCKER_VERSION_ERROR = ErrorClass( 47 "DOCKER_VERSION_ERROR", 48 "An error occured while retrieving Docker version. Please try verifying it manually." 49) 50 51 52DOCKER_PULL_ERROR = ErrorClass( 53 "DOCKER_PULL_ERROR", 54 "An error occurred while pulling a sample image. Please validate your network connection and verify if docker daemon is running properly." 55) 56 57 58# HELM ERRORS 59HELM_COMMAND_ERROR = ErrorClass( 60 "HELM_COMMAND_ERROR", 61 "Please verify if Helm is installed." 62) 63 64HELM_VERSION_ERROR = ErrorClass( 65 "HELM_VERSION_ERROR", 66 "An error occurred while retrieving Helm version. Please make sure that you have the latest Azure CLI version, and that you are using the recommended Helm version." 67) 68 69 70# CONNECTIVITY ERRORS 71CONNECTIVITY_DNS_ERROR = ErrorClass( 72 "CONNECTIVITY_DNS_ERROR", 73 "Failed to reach DNS for registry '{}'. Please check if the spelling is correct, if the CLI environment is on correct cloud and your network connectivity." 74) 75 76 77CONNECTIVITY_FORBIDDEN_ERROR = ErrorClass( 78 "CONNECTIVITY_FORBIDDEN_ERROR", 79 "Looks like you don't have access to registry '{}'. Are firewalls and virtual networks enabled?" 80) 81 82 83CONNECTIVITY_CHALLENGE_ERROR = ErrorClass( 84 "CONNECTIVITY_CHALLENGE_ERROR", 85 "Registry '{}' did not issue a challenge." 86) 87 88 89CONNECTIVITY_AAD_LOGIN_ERROR = ErrorClass( 90 "CONNECTIVITY_AAD_LOGIN_ERROR", 91 "Registry '{}' does not support AAD login." 92) 93 94 95CONNECTIVITY_REFRESH_TOKEN_ERROR = ErrorClass( 96 "CONNECTIVITY_REFRESH_TOKEN_ERROR", 97 "Access to registry '{}' was denied. Response code: {}. Please try running 'az login' again to refresh permissions." 98) 99 100 101CONNECTIVITY_ACCESS_TOKEN_ERROR = ErrorClass( 102 "CONNECTIVITY_ACCESS_TOKEN_ERROR", 103 "Access to registry '{}' was denied. Response code: {}. Please try running 'az login' again to refresh permissions." 104) 105 106 107# GENERAL ERRORS 108LOGIN_SERVER_ERROR = ErrorClass( 109 "LOGIN_SERVER_ERROR", 110 "An error occurred while retrieving the login server for registry '{}'. Please check if the spelling is correct, if the CLI environment is on correct cloud and if you have the right permissions on it." 111) 112 113 114UNEXPECTED_ERROR = ErrorClass( 115 "UNEXPECTED_ERROR", 116 "An unexpected error occurred." 117) 118