Skip to content

Commit

Permalink
refactor: consolidate similar error messages about invalid recipes (#263
Browse files Browse the repository at this point in the history
)
  • Loading branch information
patrzhan authored Nov 14, 2023
1 parent a98c019 commit 3324380
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import gdk.common.consts as consts
import gdk.common.utils as utils
from gdk.common.exceptions.error_messages import BUILT_RECIPE_SIZE_INVALID, BUILD_RECIPE_FILE_INVALID, SCHEMA_FILE_INVALID
from gdk.common.exceptions.error_messages import BUILT_RECIPE_SIZE_INVALID, PROJECT_RECIPE_FILE_INVALID, SCHEMA_FILE_INVALID


class PublishRecipeTransformer:
Expand Down Expand Up @@ -103,6 +103,6 @@ def create_publish_recipe_file(self, parsed_component_recipe) -> None:
validator = RecipeValidator(recipe_schema_path)
validator.validate_recipe(parsed_component_recipe.to_dict())
except jsonschema.exceptions.ValidationError as err:
raise Exception(BUILD_RECIPE_FILE_INVALID.format(recipe_path, err.message))
raise Exception(PROJECT_RECIPE_FILE_INVALID.format(recipe_path, err.message))
except jsonschema.exceptions.SchemaError as err:
raise Exception(SCHEMA_FILE_INVALID.format(err.message))
5 changes: 0 additions & 5 deletions gdk/common/exceptions/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
"The Greengrass recipe schema file has an unexpected error.\nPlease report it at " +
"https://github.com/aws-greengrass/aws-greengrass-gdk-cli/issues if the issue persists.\nError details: {} "
)
BUILD_RECIPE_FILE_INVALID = (
"Built recipe file '{}' is invalid. Please correct its format and try again.\nFor more information regarding " +
"component recipes refer to the docs here: https://docs.aws.amazon.com/greengrass/v2/developerguide/" +
"component-recipe-reference.html\nError: {} "
)
CLI_MODEL_FILE_NOT_EXISTS = "Model validation failed. CLI model file doesn't exist."
RECIPE_SIZE_INVALID = (
"The input recipe file '{}' has an invalid size of {} bytes. Please make sure it does not exceed 16kB"
Expand Down

0 comments on commit 3324380

Please sign in to comment.