diff --git a/broker/nats/error.go b/broker/nats/error.go index f8453929..b82c2cc8 100644 --- a/broker/nats/error.go +++ b/broker/nats/error.go @@ -13,17 +13,37 @@ const ( ) func ErrConnect(err error) error { - return errors.New(ErrConnectCode, errors.Alert, []string{"Connection to broker failed"}, []string{err.Error()}, []string{"Endpoint might not be reachable"}, []string{"Make sure the NATS endpoint is reachable"}) + return errors.New(ErrConnectCode, errors.Alert, + []string{"Connection to broker failed."}, + []string{err.Error()}, + []string{"Endpoint might not be reachable."}, + []string{"Make sure the NATS endpoint is reachable."}) } func ErrEncodedConn(err error) error { - return errors.New(ErrEncodedConnCode, errors.Alert, []string{"Encoding connection failed with broker"}, []string{err.Error()}, []string{"Endpoint might not be reachable"}, []string{"Make sure the NATS endpoint is reachable"}) + return errors.New(ErrEncodedConnCode, errors.Alert, + []string{"Encoding connection failed with broker."}, + []string{err.Error()}, + []string{"Endpoint might not be reachable."}, + []string{"Make sure the NATS endpoint is reachable."}) } func ErrPublish(err error) error { - return errors.New(ErrPublishCode, errors.Alert, []string{"Publish failed"}, []string{err.Error()}, []string{"NATS is unhealthy"}, []string{"Make sure NATS is up and running"}) + return errors.New(ErrPublishCode, errors.Alert, + []string{"Publish failed."}, + []string{err.Error()}, + []string{"NATS is unhealthy."}, + []string{"Make sure NATS is up and running."}) } func ErrPublishRequest(err error) error { - return errors.New(ErrPublishRequestCode, errors.Alert, []string{"Publish request failed"}, []string{err.Error()}, []string{"NATS is unhealthy"}, []string{"Make sure NATS is up and running"}) + return errors.New(ErrPublishRequestCode, errors.Alert, + []string{"Publish request failed."}, + []string{err.Error()}, + []string{"NATS is unhealthy."}, + []string{"Make sure NATS is up and running."}) } func ErrQueueSubscribe(err error) error { - return errors.New(ErrQueueSubscribeCode, errors.Alert, []string{"Subscription failed"}, []string{err.Error()}, []string{"NATS is unhealthy"}, []string{"Make sure NATS is up and running"}) + return errors.New(ErrQueueSubscribeCode, errors.Alert, + []string{"Subscription failed."}, + []string{err.Error()}, + []string{"NATS is unhealthy."}, + []string{"Make sure NATS is up and running."}) } diff --git a/encoding/error.go b/encoding/error.go index 5f419a29..402dcd35 100644 --- a/encoding/error.go +++ b/encoding/error.go @@ -19,29 +19,57 @@ const ( // ErrDecodeYaml is the error when the yaml unmarshal fails func ErrDecodeYaml(err error) error { - return errors.New(ErrDecodeYamlCode, errors.Alert, []string{"Error occurred while decoding YAML"}, []string{err.Error()}, []string{"Invalid object format"}, []string{"Make sure to input a valid YAML object"}) + return errors.New(ErrDecodeYamlCode, errors.Alert, + []string{"Error occurred while decoding YAML."}, + []string{err.Error()}, + []string{"Invalid YAML format or structure."}, + []string{"Please verify the YAML syntax and structure is correct."}) } func ErrUnmarshal(err error) error { - return errors.New(ErrUnmarshalCode, errors.Alert, []string{"Unmarshal unknown error: "}, []string{err.Error()}, []string{"Invalid object format"}, []string{"Make sure to input a valid JSON object"}) + return errors.New(ErrUnmarshalCode, errors.Alert, + []string{"Unknown error occurred during unmarshaling."}, + []string{err.Error()}, + []string{"The data format may be invalid or corrupted."}, + []string{"Please verify the data format matches the expected schema."}) } func ErrUnmarshalInvalid(err error, typ reflect.Type) error { - return errors.New(ErrUnmarshalInvalidCode, errors.Alert, []string{"Unmarshal invalid error for type: ", typ.String()}, []string{err.Error()}, []string{"Invalid object format"}, []string{"Make sure to input a valid JSON object"}) + return errors.New(ErrUnmarshalInvalidCode, errors.Alert, + []string{"Invalid unmarshal error for type: " + typ.String() + "."}, + []string{err.Error()}, + []string{"The data structure does not match the expected type."}, + []string{"Please ensure the data structure matches the " + typ.String() + " type definition."}) } func ErrUnmarshalSyntax(err error, offset int64) error { - return errors.New(ErrUnmarshalSyntaxCode, errors.Alert, []string{"Unmarshal syntax error at offest: ", strconv.Itoa(int(offset))}, []string{err.Error()}, []string{"Invalid object format"}, []string{"Make sure to input a valid JSON object"}) + return errors.New(ErrUnmarshalSyntaxCode, errors.Alert, + []string{"Syntax error detected during unmarshal at offset: " + strconv.Itoa(int(offset)) + "."}, + []string{err.Error()}, + []string{"The data contains invalid syntax or formatting."}, + []string{"Please check the syntax at or near position " + strconv.Itoa(int(offset)) + "."}) } func ErrUnmarshalType(err error, value string) error { - return errors.New(ErrUnmarshalTypeCode, errors.Alert, []string{"Unmarshal type error at key: %s. Error: %s", value}, []string{err.Error()}, []string{"Invalid object format"}, []string{"Make sure to input a valid JSON object"}) + return errors.New(ErrUnmarshalTypeCode, errors.Alert, + []string{"Type mismatch error at key: " + value + "."}, + []string{err.Error()}, + []string{"The data type does not match the expected type for this field."}, + []string{"Please ensure the value type matches the schema definition for key: " + value + "."}) } func ErrUnmarshalUnsupportedType(err error, typ reflect.Type) error { - return errors.New(ErrUnmarshalUnsupportedTypeCode, errors.Alert, []string{"Unmarshal unsupported type error at key: ", typ.String()}, []string{err.Error()}, []string{"Invalid object format"}, []string{"Make sure to input a valid JSON object"}) + return errors.New(ErrUnmarshalUnsupportedTypeCode, errors.Alert, + []string{"Unsupported type encountered: " + typ.String() + "."}, + []string{err.Error()}, + []string{"The data contains a type that cannot be unmarshaled."}, + []string{"Please use only supported data types in your input."}) } func ErrUnmarshalUnsupportedValue(err error, value reflect.Value) error { - return errors.New(ErrUnmarshalUnsupportedValueCode, errors.Alert, []string{"Unmarshal unsupported value error at key: ", value.String()}, []string{err.Error()}, []string{"Invalid object format"}, []string{"Make sure to input a valid JSON object"}) + return errors.New(ErrUnmarshalUnsupportedValueCode, errors.Alert, + []string{"Unsupported value encountered: " + value.String() + "."}, + []string{err.Error()}, + []string{"The data contains a value that cannot be unmarshaled."}, + []string{"Please use only supported values in your input."}) } diff --git a/generators/error.go b/generators/error.go index bf9398ca..293bf52f 100644 --- a/generators/error.go +++ b/generators/error.go @@ -7,5 +7,9 @@ var ( ) func ErrUnsupportedRegistrant(err error) error { - return errors.New(ErrUnsupportedRegistrantCode, errors.Alert, []string{"unsupported registrant"}, []string{err.Error()}, []string{"Select from one of the supported registrants"}, []string{"Check docs for the list of supported registrants"}) + return errors.New(ErrUnsupportedRegistrantCode, errors.Alert, + []string{"Unsupported registrant."}, + []string{err.Error()}, + []string{"The selected registrant is not supported by Meshery."}, + []string{"Please check the documentation for the list of supported registrants."}) } diff --git a/generators/github/error.go b/generators/github/error.go index 5834f6a8..b58b319b 100644 --- a/generators/github/error.go +++ b/generators/github/error.go @@ -12,9 +12,26 @@ const ( ) func ErrGenerateGitHubPackage(err error, pkgName string) error { - return errors.New(ErrGenerateGitHubPackageCode, errors.Alert, []string{fmt.Sprintf("error generate package for %s", pkgName)}, []string{err.Error()}, []string{"invalid sourceurl provided", "repository might be private"}, []string{"provided sourceURL according to the format", "provide approparite credentials to clone a private repository"}) + return errors.New(ErrGenerateGitHubPackageCode, errors.Alert, + []string{fmt.Sprintf("Error generating package for %s.", pkgName)}, + []string{err.Error()}, + []string{ + "Invalid source URL provided.", + "Repository might be private.", + }, + []string{ + "Provide source URL according to the format.", + "Provide appropriate credentials to clone a private repository.", + }) } func ErrInvalidGitHubSourceURL(err error) error { - return errors.New(ErrInvalidGitHubSourceURLCode, errors.Alert, []string{}, []string{err.Error()}, []string{"sourceURL provided might be invalid", "provided repo/version tag does not exist"}, []string{"ensure source url follows the format: git://////"}) + return errors.New(ErrInvalidGitHubSourceURLCode, errors.Alert, + []string{"Invalid GitHub source URL."}, + []string{err.Error()}, + []string{ + "Source URL provided might be invalid.", + "Provided repository/version tag does not exist.", + }, + []string{"Ensure source URL follows the format: git://////."}) } diff --git a/models/controllers/error.go b/models/controllers/error.go index fcb2b308..3a276df4 100644 --- a/models/controllers/error.go +++ b/models/controllers/error.go @@ -11,13 +11,28 @@ var ( ) func ErrGetControllerStatus(err error) error { - return errors.New(ErrGetControllerStatusCode, errors.Alert, []string{"Error getting the status of the meshery controller"}, []string{err.Error()}, []string{"Controller may not be healthy or not deployed"}, []string{"Make sure the controller is deployed and healthy"}) + return errors.New(ErrGetControllerStatusCode, errors.Alert, + []string{"Error getting the status of the Meshery controller."}, + []string{err.Error()}, + []string{"Controller may not be healthy or not deployed."}, + []string{"Make sure the controller is deployed and healthy."}) } func ErrDeployController(err error) error { - return errors.New(ErrDeployControllerCode, errors.Alert, []string{"Error deploying Meshery Operator"}, []string{err.Error()}, []string{"Meshery Server could not connect to the Kubernetes cluster. Meshery Operator was not deployed", "Insufficient file permission to read kubeconfig"}, []string{"Verify that the available kubeconfig is accessible by Meshery Server - verify sufficient file permissions (only needs read permission)"}) + return errors.New(ErrDeployControllerCode, errors.Alert, + []string{"Error deploying Meshery Operator."}, + []string{err.Error()}, + []string{ + "Meshery Server could not connect to the Kubernetes cluster. Meshery Operator was not deployed.", + "Insufficient file permissions to read kubeconfig.", + }, + []string{"Verify that the available kubeconfig is accessible by Meshery Server - verify sufficient file permissions (only needs read permission)."}) } func ErrGetControllerPublicEndpoint(err error) error { - return errors.New(ErrGetControllerPublicEndpointCode, errors.Alert, []string{"Could not get the public endpoint of the controller"}, []string{err.Error()}, []string{"Client configuration may not be valid"}, []string{"Make sure the client configuration is valid"}) + return errors.New(ErrGetControllerPublicEndpointCode, errors.Alert, + []string{"Could not get the public endpoint of the controller."}, + []string{err.Error()}, + []string{"Client configuration may not be valid."}, + []string{"Make sure the client configuration is valid."}) } diff --git a/models/converter/error.go b/models/converter/error.go index 6bc9e788..d21de002 100644 --- a/models/converter/error.go +++ b/models/converter/error.go @@ -11,5 +11,9 @@ const ( ) func ErrUnknownFormat(format DesignFormat) error { - return errors.New(ErrUnknownFormatCode, errors.Alert, []string{fmt.Sprintf("\"%s\" format is not supported", format)}, []string{fmt.Sprintf("Failed to export design in \"%s\" format", format)}, []string{"The format is not supported by the current version of Meshery server"}, []string{"Make sure to export design in one of the supported format"}) + return errors.New(ErrUnknownFormatCode, errors.Alert, + []string{fmt.Sprintf("The '%s' format is not supported.", format)}, + []string{fmt.Sprintf("Failed to export design in '%s' format.", format)}, + []string{"The format is not supported by the current version of Meshery server."}, + []string{"Please export the design in one of the supported formats."}) } diff --git a/models/meshmodel/core/policies/error.go b/models/meshmodel/core/policies/error.go index af514b98..3555e1d5 100644 --- a/models/meshmodel/core/policies/error.go +++ b/models/meshmodel/core/policies/error.go @@ -8,9 +8,21 @@ const ( ) func ErrPrepareForEval(err error) error { - return errors.New(ErrPrepareForEvalCode, errors.Alert, []string{"error preparing for evaluation"}, []string{err.Error()}, []string{"query might be empty", "rego store provided without associated transaction", "uncommitted transaction"}, []string{"please provide the transaction for the loaded store"}) + return errors.New(ErrPrepareForEvalCode, errors.Alert, + []string{"Error preparing for evaluation."}, + []string{err.Error()}, + []string{ + "Query might be empty.", + "Rego store provided without associated transaction.", + "Uncommitted transaction.", + }, + []string{"Please provide the transaction for the loaded store."}) } func ErrEval(err error) error { - return errors.New(ErrEvalCode, errors.Alert, []string{"error evaluating policy for the given input"}, []string{err.Error()}, []string{"The policy query is invalid, see: https://github.com/open-policy-agent/opa/blob/main/rego/resultset.go (Allowed func)"}, []string{"please provide a valid non-empty query"}) + return errors.New(ErrEvalCode, errors.Alert, + []string{"Error evaluating policy for the given input."}, + []string{err.Error()}, + []string{"The policy query is invalid. See: https://github.com/open-policy-agent/opa/blob/main/rego/resultset.go (Allowed func)."}, + []string{"Please provide a valid non-empty query."}) } diff --git a/models/meshmodel/core/v1beta1/error.go b/models/meshmodel/core/v1beta1/error.go index 50e253c0..58361b81 100644 --- a/models/meshmodel/core/v1beta1/error.go +++ b/models/meshmodel/core/v1beta1/error.go @@ -7,5 +7,9 @@ const ( ) func ErrUnknownKind(err error) error { - return errors.New(ErrUnknownKindCode, errors.Alert, []string{"unsupported connection kind detected"}, []string{err.Error()}, []string{"The component's registrant is not supported by the version of server you are running"}, []string{"Try upgrading to latest available version"}) + return errors.New(ErrUnknownKindCode, errors.Alert, + []string{"Unsupported connection kind detected."}, + []string{err.Error()}, + []string{"The component's registrant is not supported by the version of server you are running."}, + []string{"Try upgrading to the latest available version."}) } diff --git a/models/meshmodel/entity/error.go b/models/meshmodel/entity/error.go index db557fc5..a3da9c11 100644 --- a/models/meshmodel/entity/error.go +++ b/models/meshmodel/entity/error.go @@ -11,5 +11,9 @@ const ( ) func ErrUpdateEntityStatus(err error, entity string, status EntityStatus) error { - return errors.New(ErrUpdateEntityStatusCode, errors.Alert, []string{fmt.Sprintf("unable to update %s to %s", entity, status)}, []string{err.Error()}, []string{}, []string{}) + return errors.New(ErrUpdateEntityStatusCode, errors.Alert, + []string{fmt.Sprintf("Unable to update %s to %s.", entity, status)}, + []string{err.Error()}, + []string{"Entity status update failed due to internal error."}, + []string{"Please try again. If the issue persists, check the entity and status values."}) } diff --git a/models/meshmodel/registry/error.go b/models/meshmodel/registry/error.go index bf343b7f..221d144a 100644 --- a/models/meshmodel/registry/error.go +++ b/models/meshmodel/registry/error.go @@ -21,34 +21,80 @@ func ErrGetById(err error, id string) error { return errors.New( ErrUnknownHostCode, errors.Alert, - []string{"Failed to get the entity with the given ID: " + id}, + []string{"Failed to get the entity with the given ID: " + id + "."}, []string{err.Error()}, - []string{"Entity with the given ID may not be present in the registry", "Registry might be inaccessible at the moment"}, - []string{"Check if your ID is correct", "If the registry is inaccesible, please try again after some time"}, + []string{ + "Entity with the given ID may not be present in the registry.", + "Registry might be inaccessible at the moment.", + }, + []string{ + "Check if your ID is correct.", + "If the registry is inaccessible, please try again after some time.", + }, ) - } func ErrUnknownHost(err error) error { - return errors.New(ErrUnknownHostCode, errors.Alert, []string{"host is not supported"}, []string{err.Error()}, []string{"The component's host is not supported by the version of server you are running"}, []string{"Try upgrading to latest available version"}) + return errors.New(ErrUnknownHostCode, errors.Alert, + []string{"Host is not supported."}, + []string{err.Error()}, + []string{"The component's host is not supported by the version of server you are running."}, + []string{"Try upgrading to the latest available version."}) } + func ErrUnknownHostInMap() error { return errors.New( - ErrUnknownHostInMapCode, errors.Alert, []string{"Host not found in registry logs."}, nil, []string{"The specified host does not have any associated registry logs or is unrecognized.", "Ensure the host name is correct and exists in the registry logs.", "Refer to .meshery/logs/registryLogs.txt for more details."}, []string{"Verify the host name used during the registration process.", "Check the registry logs file for potential errors and additional information."}) + ErrUnknownHostInMapCode, + errors.Alert, + []string{"Host not found in registry logs."}, + nil, + []string{ + "The specified host does not have any associated registry logs or is unrecognized.", + "Ensure the host name is correct and exists in the registry logs.", + "Refer to .meshery/logs/registryLogs.txt for more details.", + }, + []string{ + "Verify the host name used during the registration process.", + "Check the registry logs file for potential errors and additional information.", + }) } func ErrEmptySchema() error { - return errors.New(ErrEmptySchemaCode, errors.Alert, []string{"Empty schema for the component"}, []string{"Empty schema for the component"}, []string{"The schema is empty for the component."}, []string{"For the particular component the schema is empty. Use the docs or discussion forum for more details "}) + return errors.New(ErrEmptySchemaCode, errors.Alert, + []string{"Empty schema for the component."}, + []string{"Empty schema for the component."}, + []string{"The schema is empty for the component."}, + []string{"The schema for this component is empty. Please refer to the documentation or discussion forum for more details."}) } + func ErrMarshalingRegisteryAttempts(err error) error { - return errors.New(ErrMarshalingRegisteryAttemptsCode, errors.Alert, []string{"Error marshaling RegisterAttempts to JSON"}, []string{"Error marshaling RegisterAttempts to JSON: ", err.Error()}, []string{}, []string{}) + return errors.New(ErrMarshalingRegisteryAttemptsCode, errors.Alert, + []string{"Error marshaling RegisterAttempts to JSON."}, + []string{"Error marshaling RegisterAttempts to JSON: " + err.Error()}, + []string{"Failed to convert RegisterAttempts data to JSON format."}, + []string{"Please check if the RegisterAttempts data is valid and properly structured."}) } + func ErrWritingRegisteryAttempts(err error) error { - return errors.New(ErrWritingRegisteryAttemptsCode, errors.Alert, []string{"Error writing RegisteryAttempts JSON data to file"}, []string{"Error writing RegisteryAttempts JSON data to file:", err.Error()}, []string{}, []string{}) + return errors.New(ErrWritingRegisteryAttemptsCode, errors.Alert, + []string{"Error writing RegisteryAttempts JSON data to file."}, + []string{"Error writing RegisteryAttempts JSON data to file: " + err.Error()}, + []string{"Failed to write RegisteryAttempts data to the specified file."}, + []string{"Please check file permissions and available disk space."}) } + func ErrRegisteringEntity(failedMsg string, hostName string) error { - return errors.New(ErrRegisteringEntityCode, errors.Alert, []string{fmt.Sprintf("One or more entities failed to register. The import process for registrant, %s, encountered the following issue: %s.", hostName, failedMsg)}, []string{fmt.Sprintf("Registrant %s encountered %s", hostName, failedMsg)}, []string{"Entity might be missing a required schema or have invalid json / yaml."}, []string{"Check `server/cmd/registery_attempts.json` for further details."}) + return errors.New(ErrRegisteringEntityCode, errors.Alert, + []string{fmt.Sprintf("One or more entities failed to register. The import process for registrant, %s, encountered the following issue: %s.", hostName, failedMsg)}, + []string{fmt.Sprintf("Registrant %s encountered %s.", hostName, failedMsg)}, + []string{"Entity might be missing a required schema or have invalid JSON/YAML."}, + []string{"Check 'server/cmd/registery_attempts.json' for further details."}) } + func ErrCreatingUserDataDirectory(dir string) error { - return errors.New(ErrCreatingUserDataDirectoryCode, errors.Fatal, []string{"Unable to create the directory for storing user data at: ", dir}, []string{"Unable to create the directory for storing user data at: ", dir}, []string{}, []string{}) + return errors.New(ErrCreatingUserDataDirectoryCode, errors.Fatal, + []string{"Unable to create the directory for storing user data at: " + dir + "."}, + []string{"Unable to create the directory for storing user data at: " + dir + "."}, + []string{"Insufficient permissions or disk space to create the directory."}, + []string{"Please ensure you have proper permissions and sufficient disk space available."}) } diff --git a/models/patterns/error.go b/models/patterns/error.go index a3044495..9f88bbf1 100644 --- a/models/patterns/error.go +++ b/models/patterns/error.go @@ -7,5 +7,9 @@ const ( ) func ErrInvalidVersion(err error) error { - return errors.New(ErrInvalidVersionCode, errors.Alert, []string{"invalid/incompatible semver version"}, []string{err.Error()}, []string{"version history for the content has been tampered outside meshery"}, []string{"rolllback to one of the previous version"}) + return errors.New(ErrInvalidVersionCode, errors.Alert, + []string{"Invalid/incompatible semver version."}, + []string{err.Error()}, + []string{"Version history for the content has been tampered with outside Meshery."}, + []string{"Roll back to one of the previous versions."}) } diff --git a/models/registration/error.go b/models/registration/error.go index eafe4e66..45257e57 100644 --- a/models/registration/error.go +++ b/models/registration/error.go @@ -19,10 +19,16 @@ func ErrSeedingComponents(err error) error { return errors.New( ErrSeedingComponentsCode, errors.Alert, - []string{"Failed to register the given models into meshery's registry"}, + []string{"Failed to register the given models into Meshery's registry."}, []string{err.Error()}, - []string{"Given models may not be in accordance with Meshery's schema", "Internal(OS level) error while reading files"}, - []string{"Make sure the models being seeded are valid in accordance with Meshery's schema", "If it is an internal error, please try again after some time"}, + []string{ + "Given models may not be in accordance with Meshery's schema.", + "Internal (OS level) error while reading files.", + }, + []string{ + "Make sure the models being seeded are valid in accordance with Meshery's schema.", + "If it is an internal error, please try again after some time.", + }, ) } @@ -30,11 +36,10 @@ func ErrMissingRegistrant(modelName string) error { return errors.New( ErrMissingRegistrantCode, errors.Alert, - []string{fmt.Sprintf("Model with name: %s does not have registrant information", modelName)}, + []string{fmt.Sprintf("Model with name: %s does not have registrant information.", modelName)}, []string{"Meshery models are always registered in context of a registrant."}, - // there is only one cause for this error - []string{""}, - []string{"Make sure that the registrant information is present in the model definition"}, + []string{"The registrant information is missing from the model definition."}, + []string{"Make sure that the registrant information is present in the model definition."}, ) } @@ -42,10 +47,16 @@ func ErrRegisterEntity(err error, name, entity string) error { return errors.New( ErrRegisterEntityCode, errors.Alert, - []string{fmt.Sprintf("Failed to register an entity of name: %s and type: %s into Meshery's registry", name, entity)}, + []string{fmt.Sprintf("Failed to register an entity of name: %s and type: %s into Meshery's registry.", name, entity)}, []string{err.Error()}, - []string{fmt.Sprintf("%s definition might be violating the definition schema", entity), fmt.Sprintf("%s might be missing model details", entity)}, - []string{fmt.Sprintf("ensure the %s definition follows the correct schema", entity), fmt.Sprintf("ensure %s definition belongs to correct model", entity)}, + []string{ + fmt.Sprintf("%s definition might be violating the definition schema.", entity), + fmt.Sprintf("%s might be missing model details.", entity), + }, + []string{ + fmt.Sprintf("Ensure the %s definition follows the correct schema.", entity), + fmt.Sprintf("Ensure %s definition belongs to correct model.", entity), + }, ) } diff --git a/utils/component/error.go b/utils/component/error.go index a37a07bb..a22bcc77 100644 --- a/utils/component/error.go +++ b/utils/component/error.go @@ -9,22 +9,57 @@ const ( ErrUpdateSchemaCode = "meshkit-11158" ) -var ErrNoSchemasFound = errors.New(ErrGetSchemaCode, errors.Alert, []string{"Could not get schema for the given openapi spec"}, []string{"The OpenAPI spec doesn't include \"components.schemas\" path"}, []string{"The spec doesn't have include any schema"}, []string{"Verify the spec has valid schema."}) +var ErrNoSchemasFound = errors.New(ErrGetSchemaCode, errors.Alert, + []string{"No schemas found in the OpenAPI specification."}, + []string{"The OpenAPI specification does not include 'components.schemas' path."}, + []string{"The specification is missing required schema definitions."}, + []string{"Please ensure the OpenAPI specification includes valid schema definitions."}) // No reference usage found. Also check in adapters before deleting func ErrCrdGenerate(err error) error { - return errors.New(ErrCrdGenerateCode, errors.Alert, []string{"Could not generate component with the given CRD"}, []string{err.Error()}, []string{""}, []string{"Verify CRD has valid schema."}) + return errors.New(ErrCrdGenerateCode, errors.Alert, + []string{"Failed to generate component from the CRD."}, + []string{err.Error()}, + []string{"The CRD schema is invalid or malformed."}, + []string{"Please verify that the CRD contains a valid schema definition."}) } // No reference usage found. Also check in adapters before deleting func ErrGetDefinition(err error) error { - return errors.New(ErrDefinitionCode, errors.Alert, []string{"Could not get definition for the given CRD"}, []string{err.Error()}, []string{""}, []string{"Verify CRD has valid schema."}) + return errors.New(ErrDefinitionCode, errors.Alert, + []string{"Failed to retrieve definition from the CRD."}, + []string{err.Error()}, + []string{"The CRD definition is invalid or missing required fields."}, + []string{"Please ensure the CRD contains all required definition fields."}) } func ErrGetSchema(err error) error { - return errors.New(ErrGetSchemaCode, errors.Alert, []string{"Could not get schema for the given CRD"}, []string{err.Error()}, []string{"Unable to marshal from cue value to JSON", "Unable to unmarshal from JSON to Go type"}, []string{"Verify CRD has valid schema.", "Malformed JSON provided", "CUE path to propery doesn't exist"}) + return errors.New(ErrGetSchemaCode, errors.Alert, + []string{"Failed to retrieve schema from the CRD."}, + []string{err.Error()}, + []string{ + "Unable to convert CUE value to JSON format.", + "Unable to parse JSON into Go type.", + }, + []string{ + "Please verify the CRD contains a valid schema.", + "Check for proper JSON formatting.", + "Ensure the CUE path to property exists.", + }) } func ErrUpdateSchema(err error, obj string) error { - return errors.New(ErrUpdateSchemaCode, errors.Alert, []string{"Failed to update schema properties for ", obj}, []string{err.Error()}, []string{"Incorrect type assertion", "Selector.Unquoted might have been invoked on non-string label", "error during conversion from cue.Selector to string"}, []string{"Ensure correct type assertion", "Perform appropriate conversion from cue.Selector to string", "Verify CRD has valid schema"}) + return errors.New(ErrUpdateSchemaCode, errors.Alert, + []string{"Failed to update schema properties for " + obj + "."}, + []string{err.Error()}, + []string{ + "Type assertion failed during schema update.", + "Invalid conversion from CUE.Selector to string.", + "Non-string label used with Selector.Unquoted.", + }, + []string{ + "Please verify type assertions are correct.", + "Ensure proper conversion from CUE.Selector to string.", + "Check that the CRD schema is valid.", + }) } diff --git a/utils/kubernetes/expose/error.go b/utils/kubernetes/expose/error.go index abc7db4f..d320a288 100644 --- a/utils/kubernetes/expose/error.go +++ b/utils/kubernetes/expose/error.go @@ -92,55 +92,107 @@ var ( var ( // ErrPodHasNoLabels is the error for pods with no labels - ErrPodHasNoLabels = errors.New(ErrPodHasNoLabelsCode, errors.Alert, []string{"the pod has no labels and cannot be exposed"}, []string{}, []string{}, []string{}) + ErrPodHasNoLabels = errors.New(ErrPodHasNoLabelsCode, errors.Alert, + []string{"The pod has no labels and cannot be exposed."}, + []string{}, + []string{"Pod definition is missing required labels."}, + []string{"Please add appropriate labels to the pod specification."}) // ErrServiceHasNoSelectors is the error for service with no selectors - ErrServiceHasNoSelectors = errors.New(ErrServiceHasNoSelectorsCode, errors.Alert, []string{"the service has no pod selector set"}, []string{}, []string{}, []string{}) + ErrServiceHasNoSelectors = errors.New(ErrServiceHasNoSelectorsCode, errors.Alert, + []string{"The service has no pod selector set."}, + []string{}, + []string{"Service definition is missing required pod selectors."}, + []string{"Please add appropriate pod selectors to the service specification."}) // ErrInvalidDeploymentNoSelectorsLabels is the error for deployment (v1beta1) with no selectors and labels - ErrInvalidDeploymentNoSelectorsLabels = errors.New(ErrInvalidDeploymentNoSelectorsLabelsCode, errors.Alert, []string{"the deployment has no labels or selectors and cannot be exposed"}, []string{}, []string{}, []string{}) + ErrInvalidDeploymentNoSelectorsLabels = errors.New(ErrInvalidDeploymentNoSelectorsLabelsCode, errors.Alert, + []string{"The deployment has no labels or selectors and cannot be exposed."}, + []string{}, + []string{"Deployment definition is missing required labels and selectors."}, + []string{"Please add appropriate labels and selectors to the deployment specification."}) // ErrInvalidDeploymentNoSelectors is the error for deployment (v1) with no selectors - ErrInvalidDeploymentNoSelectors = errors.New(ErrInvalidDeploymentNoSelectorsCode, errors.Alert, []string{"invalid deployment: no selectors, therefore cannot be exposed"}, []string{}, []string{}, []string{}) + ErrInvalidDeploymentNoSelectors = errors.New(ErrInvalidDeploymentNoSelectorsCode, errors.Alert, + []string{"Invalid deployment: No selectors present, therefore cannot be exposed."}, + []string{}, + []string{"Deployment definition is missing required selectors."}, + []string{"Please add appropriate selectors to the deployment specification."}) // ErrInvalidReplicaNoSelectorsLabels is the error for replicaset (v1beta1) with no selectors and labels - ErrInvalidReplicaNoSelectorsLabels = errors.New(ErrInvalidReplicaNoSelectorsLabelsCode, errors.Alert, []string{"the replica set has no labels or selectors and cannot be exposed"}, []string{}, []string{}, []string{}) + ErrInvalidReplicaNoSelectorsLabels = errors.New(ErrInvalidReplicaNoSelectorsLabelsCode, errors.Alert, + []string{"The replica set has no labels or selectors and cannot be exposed."}, + []string{}, + []string{"ReplicaSet definition is missing required labels and selectors."}, + []string{"Please add appropriate labels and selectors to the ReplicaSet specification."}) // ErrInvalidReplicaSetNoSelectors is the error for replicaset (v1) with no selectors - ErrInvalidReplicaSetNoSelectors = errors.New(ErrInvalidReplicaSetNoSelectorsCode, errors.Alert, []string{"invalid replicaset: no selectors, therefore cannot be exposed"}, []string{}, []string{}, []string{}) + ErrInvalidReplicaSetNoSelectors = errors.New(ErrInvalidReplicaSetNoSelectorsCode, errors.Alert, + []string{"Invalid ReplicaSet: No selectors present, therefore cannot be exposed."}, + []string{}, + []string{"ReplicaSet definition is missing required selectors."}, + []string{"Please add appropriate selectors to the ReplicaSet specification."}) // ErrNoPortsFoundForHeadlessResource is the error when no ports are found for non headless resource - ErrNoPortsFoundForHeadlessResource = errors.New(ErrNoPortsFoundForHeadlessResourceCode, errors.Alert, []string{"no ports found for the non headless resource"}, []string{}, []string{}, []string{}) + ErrNoPortsFoundForHeadlessResource = errors.New(ErrNoPortsFoundForHeadlessResourceCode, errors.Alert, + []string{"No ports found for the non-headless resource."}, + []string{}, + []string{"Resource definition is missing port specifications."}, + []string{"Please specify the required ports in the resource definition."}) ) // ErrUnknownSessionAffinityErr is the error for unknown session affinity func ErrUnknownSessionAffinityErr(sa SessionAffinity) error { - return errors.New(ErrUnknownSessionAffinityErrCode, errors.Alert, []string{"unknown session affinity:", string(sa)}, []string{}, []string{}, []string{}) + return errors.New(ErrUnknownSessionAffinityErrCode, errors.Alert, + []string{"Unknown session affinity: " + string(sa) + "."}, + []string{}, + []string{"The specified session affinity type is not supported."}, + []string{"Please use a supported session affinity type."}) } // ErrMatchExpressionsConvertionErr is the error for failed match expression conversion func ErrMatchExpressionsConvertionErr(me []metav1.LabelSelectorRequirement) error { - return errors.New(ErrMatchExpressionsConvertionErrCode, errors.Alert, []string{"couldn't convert expressions - to map-based selector format"}, []string{}, []string{}, []string{}) + return errors.New(ErrMatchExpressionsConvertionErrCode, errors.Alert, + []string{"Could not convert expressions to map-based selector format."}, + []string{}, + []string{"Label selector expressions are invalid or unsupported."}, + []string{"Please verify the label selector expressions are valid."}) } // ErrFailedToExtractPodSelectorErr is the error for failed to extract pod selector func ErrFailedToExtractPodSelectorErr(object runtime.Object) error { - return errors.New(ErrFailedToExtractPodSelectorErrCode, errors.Alert, []string{"cannot extract pod selector from ", object.GetObjectKind().GroupVersionKind().Kind}, []string{}, []string{}, []string{}) + return errors.New(ErrFailedToExtractPodSelectorErrCode, errors.Alert, + []string{"Cannot extract pod selector from " + object.GetObjectKind().GroupVersionKind().Kind + "."}, + []string{}, + []string{"Resource definition has invalid or missing pod selectors."}, + []string{"Please ensure the resource has valid pod selectors defined."}) } // ErrFailedToExtractPorts is the error for failed to extract ports func ErrFailedToExtractPorts(object runtime.Object) error { - return errors.New(ErrFailedToExtractPortsCode, errors.Alert, []string{"cannot extract ports from ", object.GetObjectKind().GroupVersionKind().Kind}, []string{}, []string{}, []string{}) + return errors.New(ErrFailedToExtractPortsCode, errors.Alert, + []string{"Cannot extract ports from " + object.GetObjectKind().GroupVersionKind().Kind + "."}, + []string{}, + []string{"Resource definition has invalid or missing port specifications."}, + []string{"Please ensure the resource has valid port specifications defined."}) } // ErrFailedToExtractProtocolsErr is the error for extracting ports func ErrFailedToExtractProtocolsErr(object runtime.Object) error { - return errors.New(ErrFailedToExtractProtocolsErrCode, errors.Alert, []string{"cannot extract protocols from ", object.GetObjectKind().GroupVersionKind().Kind}, []string{}, []string{}, []string{}) + return errors.New(ErrFailedToExtractProtocolsErrCode, errors.Alert, + []string{"Cannot extract protocols from " + object.GetObjectKind().GroupVersionKind().Kind + "."}, + []string{}, + []string{"Resource definition has invalid or missing protocol specifications."}, + []string{"Please ensure the resource has valid protocol specifications defined."}) } // ErrCannotExposeObjectErr is the error if the given object cannot be exposed func ErrCannotExposeObjectErr(kind schema.GroupKind) error { - return errors.New(ErrCannotExposeObjectErrCode, errors.Alert, []string{"cannot expose a ", kind.String()}, []string{}, []string{}, []string{}) + return errors.New(ErrCannotExposeObjectErrCode, errors.Alert, + []string{"Cannot expose a " + kind.String() + "."}, + []string{}, + []string{"The specified resource type cannot be exposed."}, + []string{"Please verify that the resource type supports being exposed."}) } // Meshkit errors - These errors are intended to wrap more specific errors while maintaining @@ -148,62 +200,105 @@ func ErrCannotExposeObjectErr(kind schema.GroupKind) error { // ErrExposeResource is the error when there is an error exposing the kubernetes resource func ErrExposeResource(err error) error { - return errors.New(ErrExposeResourceCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrExposeResourceCode, errors.Alert, + []string{"Failed to expose the Kubernetes resource."}, + []string{err.Error()}, + []string{"Resource configuration may be invalid or insufficient permissions."}, + []string{"Please verify the resource configuration and permissions."}) } // ErrGettingResource is the error when there is an error getting the kubernetes resource func ErrGettingResource(err error) error { - return errors.New(ErrGettingResourceCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrGettingResourceCode, errors.Alert, + []string{"Failed to get the Kubernetes resource."}, + []string{err.Error()}, + []string{"Resource may not exist or insufficient permissions."}, + []string{"Please verify the resource exists and check permissions."}) } // ErrTraverser is the error is collection of error generated while traversing the resources func ErrTraverser(err error) error { - return errors.New(ErrTraverserCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrTraverserCode, errors.Alert, + []string{"Error traversing Kubernetes resources."}, + []string{err.Error()}, + []string{"Resource structure may be invalid or permissions insufficient."}, + []string{"Please verify resource structure and permissions."}) } // ErrResourceCannotBeExposed is the error if the given resource cannot be exposed func ErrResourceCannotBeExposed(err error, resourceKind string) error { - return errors.New(ErrResourceCannotBeExposedCode, - errors.Alert, []string{"resource type %s cannot be exposed: ", resourceKind}, []string{err.Error()}, []string{}, []string{}) + return errors.New(ErrResourceCannotBeExposedCode, errors.Alert, + []string{"Resource type " + resourceKind + " cannot be exposed."}, + []string{err.Error()}, + []string{"The resource type does not support being exposed."}, + []string{"Please verify that the resource type can be exposed."}) } // ErrSelectorBasedMap is the error when the given resource's selectors can't // be parsed to a map func ErrSelectorBasedMap(err error) error { - return errors.New(ErrSelectorBasedMapCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrSelectorBasedMapCode, errors.Alert, + []string{"Failed to parse resource selectors to map."}, + []string{err.Error()}, + []string{"Selector format may be invalid."}, + []string{"Please verify the selector format is correct."}) } // ErrProtocolBasedMap is the error when the given resource's protocols can't // be parsed to a map func ErrProtocolBasedMap(err error) error { - return errors.New(ErrProtocolBasedMapCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrProtocolBasedMapCode, errors.Alert, + []string{"Failed to parse resource protocols to map."}, + []string{err.Error()}, + []string{"Protocol format may be invalid."}, + []string{"Please verify the protocol format is correct."}) } // ErrLabelBasedMap is the error when the given resource's labels can't // be parsed to a map func ErrLabelBasedMap(err error) error { - return errors.New(ErrLableBasedMapCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrLableBasedMapCode, errors.Alert, + []string{"Failed to parse resource labels to map."}, + []string{err.Error()}, + []string{"Label format may be invalid."}, + []string{"Please verify the label format is correct."}) } // ErrPortParsing is the error when the given resource's ports can't // be parsed to a slice func ErrPortParsing(err error) error { - return errors.New(ErrPortParsingCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrPortParsingCode, errors.Alert, + []string{"Failed to parse resource ports to slice."}, + []string{err.Error()}, + []string{"Port specification format may be invalid."}, + []string{"Please verify the port specification format is correct."}) } // ErrGenerateService is the error when a service cannot be generated // for the given resource func ErrGenerateService(err error) error { - return errors.New(ErrGenerateServiceCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrGenerateServiceCode, errors.Alert, + []string{"Failed to generate service for the resource."}, + []string{err.Error()}, + []string{"Resource configuration may be invalid for service generation."}, + []string{"Please verify the resource configuration is valid for service generation."}) } // ErrConstructingRestHelper is the error when a rest helper cannot be generated // for the generated service func ErrConstructingRestHelper(err error) error { - return errors.New(ErrConstructingRestHelperCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrConstructingRestHelperCode, errors.Alert, + []string{"Failed to construct REST helper for the service."}, + []string{err.Error()}, + []string{"Service configuration may be invalid for REST helper construction."}, + []string{"Please verify the service configuration is valid."}) } // ErrCreatingService is the error when there is an error deploying the service func ErrCreatingService(err error) error { - return errors.New(ErrCreatingServiceCode, errors.Alert, []string{err.Error()}, []string{}, []string{}, []string{}) + return errors.New(ErrCreatingServiceCode, errors.Alert, + []string{"Failed to create the service."}, + []string{err.Error()}, + []string{"Service configuration may be invalid or insufficient permissions."}, + []string{"Please verify the service configuration and permissions."}) } diff --git a/utils/kubernetes/kompose/error.go b/utils/kubernetes/kompose/error.go index fa3f9548..38c3eae4 100644 --- a/utils/kubernetes/kompose/error.go +++ b/utils/kubernetes/kompose/error.go @@ -10,15 +10,39 @@ const ( ) func ErrCvrtKompose(err error) error { - return errors.New(ErrCvrtKomposeCode, errors.Alert, []string{"Error converting the docker compose file into kubernetes manifests"}, []string{err.Error()}, []string{"Could not convert docker-compose file into kubernetes manifests"}, []string{"Make sure the docker-compose file is valid", ""}) + return errors.New(ErrCvrtKomposeCode, errors.Alert, + []string{"Error converting the Docker Compose file into Kubernetes manifests."}, + []string{err.Error()}, + []string{"Could not convert Docker Compose file into Kubernetes manifests."}, + []string{"Make sure the Docker Compose file is valid."}) } func ErrValidateDockerComposeFile(err error) error { - return errors.New(ErrValidateDockerComposeFileCode, errors.Alert, []string{"Invalid docker compose file"}, []string{err.Error()}, []string{""}, []string{"Make sure that the compose file is valid,", "Make sure that the schema is valid"}) + return errors.New(ErrValidateDockerComposeFileCode, errors.Alert, + []string{"Invalid Docker Compose file."}, + []string{err.Error()}, + []string{"The Docker Compose file format is invalid."}, + []string{ + "Make sure that the compose file is valid.", + "Make sure that the schema is valid.", + }) } + func ErrIncompatibleVersion() error { - return errors.New(ErrIncompatibleVersionCode, errors.Alert, []string{"This version of docker compose file is not compatible."}, []string{"This docker compose file is invalid since it's version is incompatible."}, []string{"docker compose file with version greater than 3.3 is probably being used"}, []string{"Make sure that the compose file has version less than or equal to 3.3,", ""}) + return errors.New(ErrIncompatibleVersionCode, errors.Alert, + []string{"This version of Docker Compose file is not compatible."}, + []string{"This Docker Compose file is invalid since its version is incompatible."}, + []string{"Docker Compose file with version greater than 3.3 is being used."}, + []string{"Make sure that the compose file has version less than or equal to 3.3."}) } + func ErrNoVersion() error { - return errors.New(ErrNoVersionCode, errors.Alert, []string{"version not found in the docker compose file"}, []string{"Version field not found"}, []string{"Since the Docker Compose specification does not mandate the version field from version 3 onwards, most sources do not provide them."}, []string{"Make sure that the compose file has version specified,", "Add any version less than or equal to 3.3 if you cannot get the exact version from the source"}) + return errors.New(ErrNoVersionCode, errors.Alert, + []string{"Version not found in the Docker Compose file."}, + []string{"Version field not found."}, + []string{"Since the Docker Compose specification does not mandate the version field from version 3 onwards, most sources do not provide them."}, + []string{ + "Make sure that the compose file has version specified.", + "Add any version less than or equal to 3.3 if you cannot get the exact version from the source.", + }) } diff --git a/utils/manifests/error.go b/utils/manifests/error.go index 0f6a19df..93da39cd 100644 --- a/utils/manifests/error.go +++ b/utils/manifests/error.go @@ -14,29 +14,72 @@ const ( ) func ErrGetResourceIdentifier(err error) error { - return errors.New(ErrGetResourceIdentifierCode, errors.Alert, []string{"Error extracting the resource identifier name"}, []string{err.Error()}, []string{"Could not extract the value with the given filter configuration"}, []string{"Make sure to input a valid manifest", "Make sure to provide the right filter configurations", "Make sure the filters are appropriate for the given manifest"}) + return errors.New(ErrGetResourceIdentifierCode, errors.Alert, + []string{"Error extracting the resource identifier name."}, + []string{err.Error()}, + []string{"Could not extract the value with the given filter configuration."}, + []string{ + "Make sure to input a valid manifest.", + "Make sure to provide the right filter configurations.", + "Make sure the filters are appropriate for the given manifest.", + }) } func ErrGetCrdNames(err error) error { - return errors.New(ErrGetCrdNamesCode, errors.Alert, []string{"Error getting crd names"}, []string{err.Error()}, []string{"Could not execute kubeopenapi-jsonschema correctly"}, []string{"Make sure the binary is valid and correct", "Make sure the filter passed is correct"}) + return errors.New(ErrGetCrdNamesCode, errors.Alert, + []string{"Error getting CRD names."}, + []string{err.Error()}, + []string{"Could not execute kubeopenapi-jsonschema correctly."}, + []string{ + "Make sure the binary is valid and correct.", + "Make sure the filter passed is correct.", + }) } func ErrGetSchemas(err error) error { - return errors.New(ErrGetSchemasCode, errors.Alert, []string{"Error getting schemas"}, []string{err.Error()}, []string{"Schemas Json could not be produced from given crd."}, []string{"Make sure the filter passed is correct"}) + return errors.New(ErrGetSchemasCode, errors.Alert, + []string{"Error getting schemas."}, + []string{err.Error()}, + []string{"Schemas JSON could not be produced from given CRD."}, + []string{"Make sure the filter passed is correct."}) } + func ErrGetAPIVersion(err error) error { - return errors.New(ErrGetAPIVersionCode, errors.Alert, []string{"Error getting api version"}, []string{err.Error()}, []string{"Api version could not be parsed"}, []string{"Make sure the filter passed is correct"}) + return errors.New(ErrGetAPIVersionCode, errors.Alert, + []string{"Error getting API version."}, + []string{err.Error()}, + []string{"API version could not be parsed."}, + []string{"Make sure the filter passed is correct."}) } + func ErrGetAPIGroup(err error) error { - return errors.New(ErrGetAPIGroupCode, errors.Alert, []string{"Error getting api group"}, []string{err.Error()}, []string{"Api group could not be parsed"}, []string{"Make sure the filter passed is correct"}) + return errors.New(ErrGetAPIGroupCode, errors.Alert, + []string{"Error getting API group."}, + []string{err.Error()}, + []string{"API group could not be parsed."}, + []string{"Make sure the filter passed is correct."}) } func ErrPopulatingYaml(err error) error { - return errors.New(ErrPopulatingYamlCode, errors.Alert, []string{"Error populating yaml"}, []string{err.Error()}, []string{"Yaml could not be populated with the returned manifests"}, []string{""}) + return errors.New(ErrPopulatingYamlCode, errors.Alert, + []string{"Error populating YAML."}, + []string{err.Error()}, + []string{"YAML could not be populated with the returned manifests."}, + []string{"Please verify the manifest format and try again."}) } + func ErrAbsentFilter(err error) error { - return errors.New(ErrAbsentFilterCode, errors.Alert, []string{"Error with passed filters"}, []string{err.Error()}, []string{"ItrFilter or ItrSpecFilter is either not passed or empty"}, []string{"Pass the correct ItrFilter and ItrSpecFilter"}) + return errors.New(ErrAbsentFilterCode, errors.Alert, + []string{"Error with passed filters."}, + []string{err.Error()}, + []string{"ItrFilter or ItrSpecFilter is either not passed or empty."}, + []string{"Please pass the correct ItrFilter and ItrSpecFilter."}) } + func ErrCreatingDirectory(err error) error { - return errors.New(ErrCreatingDirectoryCode, errors.Alert, []string{"could not create directory"}, []string{err.Error()}, []string{"proper file permissions were not set"}, []string{"check the appropriate file permissions"}) + return errors.New(ErrCreatingDirectoryCode, errors.Alert, + []string{"Could not create directory."}, + []string{err.Error()}, + []string{"Proper file permissions were not set."}, + []string{"Please check the appropriate file permissions."}) } diff --git a/utils/walker/error.go b/utils/walker/error.go index 02b49719..9756361f 100644 --- a/utils/walker/error.go +++ b/utils/walker/error.go @@ -8,9 +8,17 @@ var ( ) func ErrCloningRepo(err error) error { - return errors.New(ErrCloningRepoCode, errors.Alert, []string{"could not clone the repo"}, []string{err.Error()}, []string{}, []string{}) + return errors.New(ErrCloningRepoCode, errors.Alert, + []string{"Could not clone the repository."}, + []string{err.Error()}, + []string{"Repository might be inaccessible or invalid."}, + []string{"Make sure the repository URL is correct and accessible."}) } func ErrInvalidSizeFile(err error) error { - return errors.New(ErrInvalidSizeFileCode, errors.Alert, []string{err.Error()}, []string{"Could not read the file while walking the repo"}, []string{"Given file size is either 0 or exceeds the limit of 50 MB"}, []string{""}) + return errors.New(ErrInvalidSizeFileCode, errors.Alert, + []string{err.Error()}, + []string{"Could not read the file while walking the repository."}, + []string{"Given file size is either 0 or exceeds the limit of 50 MB."}, + []string{"Please ensure the file size is within the acceptable range (0-50 MB)."}) }