Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
added collection/table to InvalidFieldException (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lapsus authored and binal-7span committed May 15, 2019
1 parent 77fb20f commit 7393cb8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class InvalidFieldException extends UnprocessableEntityException
{
const ERROR_CODE = 202;

public function __construct($field)
public function __construct($field, $collection)
{
$message = sprintf('Invalid field "%s"', $field);
$message = sprintf('Invalid field "%s" in "%s"', $field, $collection);

parent::__construct($message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ protected function doFilter(Builder $query, $column, $condition, $table)
);

if (!$field) {
throw new Exception\InvalidFieldException($fieldName);
throw new Exception\InvalidFieldException($fieldName, $table);
}

$condition = $this->parseCondition($condition);
Expand Down Expand Up @@ -1641,7 +1641,7 @@ protected function processSort(Builder $query, array $columns)

$field = SchemaService::getField($this->table, $orderBy, false, $this->acl === null);
if ($orderBy !== '?' && !$field) {
throw new Exception\InvalidFieldException($column);
throw new Exception\InvalidFieldException($column, $this->table);
}

if ($field && $field->isAlias()) {
Expand Down Expand Up @@ -2102,7 +2102,7 @@ public function validateFields(array $fields)

foreach ($selectedFields as $field) {
if (!$collection->hasField($field)) {
throw new Exception\InvalidFieldException($field);
throw new Exception\InvalidFieldException($field, $collection->getName());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Directus/Services/TablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ protected function getAllFieldsParams(array $params)
foreach ($sort as $field) {
$field = (string)$field;
if (!$collection->hasField($field)) {
throw new InvalidFieldException($field);
throw new InvalidFieldException($field, $collection->getName());
}
}
}
Expand Down

0 comments on commit 7393cb8

Please sign in to comment.