Browse Source
Merge pull request #1999 from doccano/enhancement/handleJSONDecodeError
Handle JSONDecodeError on testing auto labeling API
pull/2000/head
Hiroki Nakayama
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
0 deletions
-
backend/auto_labeling/exceptions.py
-
backend/auto_labeling/views.py
|
|
@ -24,3 +24,7 @@ class SampleDataException(ValidationError): |
|
|
|
|
|
|
|
class TemplateMappingError(ValidationError): |
|
|
|
default_detail = "The response cannot be mapped. You might need to change the template." |
|
|
|
|
|
|
|
|
|
|
|
class ResponseJSONDecodeError(ValidationError): |
|
|
|
default_detail = "The response cannot be decoded." "Please try to return the response in dictionary or list format." |
|
|
@ -17,6 +17,7 @@ from rest_framework.views import APIView |
|
|
|
|
|
|
|
from .exceptions import ( |
|
|
|
AWSTokenError, |
|
|
|
ResponseJSONDecodeError, |
|
|
|
SampleDataException, |
|
|
|
TemplateMappingError, |
|
|
|
URLConnectionError, |
|
|
@ -94,6 +95,8 @@ class RestAPIRequestTesting(APIView): |
|
|
|
raise URLConnectionError |
|
|
|
except botocore.exceptions.ClientError: |
|
|
|
raise AWSTokenError() |
|
|
|
except json.decoder.JSONDecodeError: |
|
|
|
raise ResponseJSONDecodeError() |
|
|
|
except Exception as e: |
|
|
|
raise e |
|
|
|
|
|
|
|