appwrite/src/Appwrite/Utopia/Response/Model/Error.php

60 lines
1.4 KiB
PHP
Raw Normal View History

2020-06-23 15:01:20 +00:00
<?php
namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
class Error extends Model
{
public function __construct()
{
$this
->addRule('message', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
2020-06-23 15:01:20 +00:00
'description' => 'Error message.',
2021-01-13 15:06:36 +00:00
'default' => '',
2020-06-23 15:01:20 +00:00
'example' => 'Not found',
])
->addRule('code', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
2020-06-23 15:01:20 +00:00
'description' => 'Error code.',
2021-01-13 15:06:36 +00:00
'default' => '',
2020-06-23 15:01:20 +00:00
'example' => '404',
])
2022-02-01 08:39:07 +00:00
->addRule('type', [
'type' => self::TYPE_STRING,
2022-02-08 16:52:02 +00:00
'description' => 'Error type. You can learn more about all the error types at https://appwrite.io/docs/error-codes#errorTypes',
'default' => 'unknown',
2022-02-01 08:39:07 +00:00
'example' => 'not_found',
])
2020-06-23 15:01:20 +00:00
->addRule('version', [
2020-11-07 22:14:48 +00:00
'type' => self::TYPE_STRING,
2020-06-23 15:01:20 +00:00
'description' => 'Server version number.',
2021-01-13 15:06:36 +00:00
'default' => '',
'example' => '1.0',
2020-06-23 15:01:20 +00:00
])
;
}
/**
* Get Name
*
2020-06-23 15:01:20 +00:00
* @return string
*/
2022-05-23 14:54:50 +00:00
public function getName(): string
2020-06-23 15:01:20 +00:00
{
return 'Error';
}
/**
2021-12-15 10:19:29 +00:00
* Get Type
*
2020-06-23 15:01:20 +00:00
* @return string
*/
2022-05-23 14:54:50 +00:00
public function getType(): string
2020-06-23 15:01:20 +00:00
{
return Response::MODEL_ERROR;
}
}