mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 11:09:53 +00:00
6bdd1a6756
Main motivation behind this change is to be able to catch exceptions as per raise_for_errors() helpers, but to inspect state of exceptions instead of just getting a rendered string. This allows rendering exceptions into JSON, for example.
40 lines
918 B
Python
40 lines
918 B
Python
from openapi_core.schema.exceptions import OpenAPIMappingError
|
|
|
|
import attr
|
|
|
|
|
|
class OpenAPIParameterError(OpenAPIMappingError):
|
|
pass
|
|
|
|
|
|
@attr.s
|
|
class MissingParameter(OpenAPIParameterError):
|
|
name = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Missing parameter (without default value): {0}".format(self.name)
|
|
|
|
|
|
@attr.s
|
|
class MissingRequiredParameter(OpenAPIParameterError):
|
|
name = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Missing required parameter: {0}".format(self.name)
|
|
|
|
|
|
@attr.s
|
|
class EmptyParameterValue(OpenAPIParameterError):
|
|
name = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Value of parameter cannot be empty: {0}".format(self.name)
|
|
|
|
|
|
@attr.s
|
|
class InvalidParameterValue(OpenAPIParameterError):
|
|
name = attr.ib()
|
|
original_exception = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Invalid parameter value for `{0}`: {1}".format(sef.name, self.original_exception)
|