Unverified Commit 1608acbf authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

EFA: check for (and report) backend errors

parent ebcdfc7f
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -43,7 +43,8 @@ sub new_p {
				say $self->{json}->pretty->encode( $self->{response} );
			}

			$self->check_for_ambiguous();
			$self->check_for_ambiguous;
			$self->check_for_error;

			if ( $self->{errstr} ) {
				$promise->reject( $self->{errstr}, $self );
@@ -297,7 +298,8 @@ sub new {
		say $self->{json}->pretty->encode( $self->{response} );
	}

	$self->check_for_ambiguous();
	$self->check_for_ambiguous;
	$self->check_for_error;

	return $self;
}
@@ -418,6 +420,23 @@ sub place_candidates {
	return;
}

sub check_for_error {
	my ($self) = @_;

	my $json = $self->{response};

	my %kv;
	for my $m ( @{ $json->{dm}{message} // [] } ) {
		$kv{ $m->{name} } = $m->{value};
	}

	if ( $kv{error} ) {
		$self->{errstr} = "Backend error: $kv{error}";
	}

	return;
}

sub check_for_ambiguous {
	my ($self) = @_;