Mailchimp_Helpers::log_action_error( $response,  $user_id,  $action_data,  $recipe_id )

Method log_action_error


Parameters Parameters

$response

(Required)

$user_id

(Required)

$action_data

(Required)

$recipe_id

(Required)


Top ↑

Return Return

(void)


Source Source

File: src/integrations/mailchimp/helpers/mailchimp-helpers.php

	public function log_action_error( $response, $user_id, $action_data, $recipe_id ) {
		global $uncanny_automator;
		// log error when no token found.
		$error_msg = __( 'API error: ', 'uncanny-automator' );
		if ( isset( $response->data->title ) ) {
			$error_msg .= ' ' . $response->data->title;
		}
		if ( isset( $response->data->detail ) ) {
			$error_msg .= ' ' . $response->data->detail;
		}
		if ( isset( $response->data->errors ) ) {
			foreach ( $response->data->errors as $error ) {
				$error_msg .= ' ' . $error->field;
				$error_msg .= ' ' . $error->message;
			}
		}
		if ( isset( $response->error->type ) ) {
			$error_msg .= ' ' . $response->error->type;
		}
		if ( isset( $response->error->description ) ) {
			$error_msg .= ' ' . $response->error->description;
		}
		$action_data['do-nothing']           = true;
		$action_data['complete_with_errors'] = true;
		$uncanny_automator->complete_action( $user_id, $action_data, $recipe_id, $error_msg );
	}