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

added collection/table to InvalidFieldException #956

Merged
merged 1 commit into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1318,7 +1318,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 @@ -1587,7 +1587,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 @@ -2048,7 +2048,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