Skip to content

Commit

Permalink
Replace abort() with raise SanicException
Browse files Browse the repository at this point in the history
This is for compatibility with newly-released Sanic 21.12 which removed the deprecated `abort()` in sanic-org/sanic#2306. Before that, it was a simple wrapper around `raise SanicException` (https://github.com/sanic-org/sanic/blob/523db190a732177eda5a641768667173ba2e2452/sanic/exceptions.py#L262-L265), so this change makes it explicit and removes the dependency on `abort()`.
  • Loading branch information
mildbyte committed Dec 28, 2021
1 parent 3c442dc commit a96d100
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions strawberry/sanic/views.py
@@ -1,7 +1,7 @@
import json
from typing import Any

from sanic.exceptions import ServerError, abort
from sanic.exceptions import SanicException, ServerError
from sanic.request import Request
from sanic.response import HTTPResponse, html
from sanic.views import HTTPMethodView
Expand Down Expand Up @@ -57,7 +57,7 @@ def process_result(self, result: ExecutionResult) -> GraphQLHTTPResponse:

async def get(self, request: Request) -> HTTPResponse:
if not self.graphiql:
abort(404)
raise SanicException(status_code=404)

template = render_graphiql_page()
return self.render_template(template=template)
Expand Down Expand Up @@ -101,5 +101,5 @@ def parse_body(self, request: Request) -> dict:
try:
return replace_placeholders_with_files(operations, files_map, files)
except KeyError:
abort(400, "File(s) missing in form data")
raise SanicException(status_code=400, message="File(s) missing in form data")
return request.json

0 comments on commit a96d100

Please sign in to comment.