Beispiel #1
0
 /**
  * Format error for output.
  *
  * @param  Error  $e
  * @return array
  */
 public function formatError(Error $e)
 {
     $error = ['message' => $e->getMessage()];
     $locations = $e->getLocations();
     if (!empty($locations)) {
         $error['locations'] = array_map(function ($location) {
             return $location->toArray();
         }, $locations);
     }
     $previous = $e->getPrevious();
     if ($previous && $previous instanceof ValidationError) {
         $error['validation'] = $previous->getValidatorMessages();
     }
     return $error;
 }