Skip to content

Commit

Permalink
added error for color palattes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayadav09 committed Jan 11, 2024
1 parent 213b6cb commit 8d7ce5a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion includes/Services/SiteGenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ public static function process_homepages_response(
$versions = array();
// Fetch the color palette data from the options table.
$color_palettes = self::get_color_palattes();

if ( is_wp_error( $color_palettes ) ) {
return new \WP_Error(
'nfd_onboarding_error',
__( 'Cannot retrieve color palatte', 'wp-module-onboarding' ),
array( 'status' => 400 )
);
}

// Decode the color palettes if it's not an array (assuming it's a JSON string).
if ( ( is_string( $color_palettes ) ) ) {
$color_palettes = json_decode( $color_palettes, true );
Expand Down Expand Up @@ -487,7 +496,7 @@ public static function get_color_palattes() {
'color_palette'
);

if ( isset( $color_palette['error'] ) || is_wp_error( $color_palette ) ) {
if ( is_wp_error( $color_palette ) ) {
return new \WP_Error(
'nfd_onboarding_error',
__( 'Cannot retrieve color palatte', 'wp-module-onboarding' ),
Expand All @@ -512,6 +521,14 @@ public static function process_favorited_regenerate(
$versions = array();
// Fetch the color palette data from the options table.
$color_palettes = self::get_color_palattes();

if ( is_wp_error( $color_palettes ) ) {
return new \WP_Error(
'nfd_onboarding_error',
__( 'Cannot retrieve color palatte', 'wp-module-onboarding' ),
array( 'status' => 400 )
);
}
// Decode the color palettes if it's not an array (assuming it's a JSON string).
if ( ( is_string( $color_palettes ) ) ) {
$color_palettes = json_decode( $color_palettes, true );
Expand Down

0 comments on commit 8d7ce5a

Please sign in to comment.