Compare commits

...
3 changed files with 20 additions and 4 deletions
+5
View File
@@ -851,6 +851,11 @@ return [
'description' => 'The maximum number or size of attributes for collection \'%s\' has been reached.',
'code' => 400,
],
Exception::ATTRIBUTE_ROW_WIDTH_LIMIT_EXCEEDED => [
'name' => Exception::ATTRIBUTE_ROW_WIDTH_LIMIT_EXCEEDED,
'description' => 'The maximum row width for collection \'%s\' has been reached. Try reducing the size of the attributes.',
'code' => 400,
],
Exception::ATTRIBUTE_VALUE_INVALID => [
'name' => Exception::ATTRIBUTE_VALUE_INVALID,
'description' => 'The attribute value is invalid. Please check the type, range and value of the attribute.',
+1
View File
@@ -233,6 +233,7 @@ class Exception extends \Exception
public const string ATTRIBUTE_DEFAULT_UNSUPPORTED = 'attribute_default_unsupported';
public const string ATTRIBUTE_ALREADY_EXISTS = 'attribute_already_exists';
public const string ATTRIBUTE_LIMIT_EXCEEDED = 'attribute_limit_exceeded';
public const string ATTRIBUTE_ROW_WIDTH_LIMIT_EXCEEDED = 'attribute_row_width_limit_exceeded';
public const string ATTRIBUTE_VALUE_INVALID = 'attribute_value_invalid';
public const string ATTRIBUTE_TYPE_INVALID = 'attribute_type_invalid';
public const string ATTRIBUTE_INVALID_RESIZE = 'attribute_invalid_resize';
@@ -383,8 +383,13 @@ abstract class Action extends UtopiaAction
$attribute = $dbForProject->createDocument('attributes', $attribute);
} catch (DuplicateException) {
throw new Exception($this->getDuplicateException(), params: [$key]);
} catch (LimitException) {
throw new Exception($this->getLimitException(), params: [$collectionId]);
} catch (LimitException $e) {
$message = $e->getMessage();
if (\str_contains($message, 'Row width limit reached')) {
// More specific error when row width limit is exceeded.
throw new Exception(Exception::ATTRIBUTE_ROW_WIDTH_LIMIT_EXCEEDED, params: [$collectionId]);
}
throw new Exception($this->getLimitException(), $message, params: [$collectionId]);
} catch (StructureException $e) {
throw new Exception($this->getStructureException(), $e->getMessage());
} catch (Throwable $e) {
@@ -627,8 +632,13 @@ abstract class Action extends UtopiaAction
throw new Exception($this->getDuplicateException(), params: [$key]);
} catch (IndexException $e) {
throw new Exception($this->getInvalidIndexException(), $e->getMessage());
} catch (LimitException) {
throw new Exception($this->getLimitException(), params: [$collectionId]);
} catch (LimitException $e) {
$message = $e->getMessage();
if (\str_contains($message, 'Row width limit reached')) {
// More specific error when row width limit is exceeded.
throw new Exception(Exception::ATTRIBUTE_ROW_WIDTH_LIMIT_EXCEEDED, params: [$collectionId]);
}
throw new Exception($this->getLimitException(), $message, params: [$collectionId]);
} catch (TruncateException) {
throw new Exception($this->getInvalidResizeException());
}