Webiny\Component\Rest\Response\CallbackResult::addErrorMessage PHP Method

addErrorMessage() public method

Appends an error entry to the output.
public addErrorMessage ( array $error )
$error array Error data
    public function addErrorMessage(array $error)
    {
        $this->outputArray['errorReport']['errors'][] = $error;
        return $this;
    }

Usage Example

 public function testGetErrorTrue()
 {
     $cr = new CallbackResult();
     $cr->setErrorResponse('Error message', 'Error desc', '555');
     $cr->addErrorMessage(['ref' => 'testing']);
     $error = $cr->getError();
     $this->assertNotFalse($error);
     $this->assertSame('testing', $error['errors'][0]['ref']);
 }