Skip to content

Commit 465ba62

Browse files
author
Tristen Harr
committed
update to add error handling
1 parent 1a8f46a commit 465ba62

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This changelog documents the changes between release versions.
44
## [Unreleased]
55
Changes to be included in the next upcoming release
66

7+
## [0.0.38] - 2024-08-08
8+
* Add errors and error handling to SDK
9+
710
## [0.0.37] - 2024-08-07
811
* Fix schema endpoint to be aware of parallel execution
912

connector-definition/template/functions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from hasura_ndc.function_connector import FunctionConnector
1414
from pydantic import BaseModel # You only need this import if you plan to have complex inputs/outputs, which function similar to how frameworks like FastAPI do
1515
import asyncio # You might not need this import if you aren't doing asynchronous work
16+
from hasura_ndc.errors import UnprocessableContent
1617

1718
connector = FunctionConnector()
1819

@@ -99,5 +100,11 @@ async def parallel_query(name: str) -> str:
99100
await asyncio.sleep(1)
100101
return f"Hello {name}"
101102

103+
# This is an example of how you can throw an error
104+
# There are different error types including: BadRequest, Forbidden, Conflict, UnprocessableContent, InternalServerError, NotSupported, and BadGateway
105+
@connector.register_query
106+
def error():
107+
raise UnprocessableContent(message="This is a error", details={"Error": "This is a error!"})
108+
102109
if __name__ == "__main__":
103110
start(connector)

connector-definition/template/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fastapi==0.110.2
99
googleapis-common-protos==1.63.0
1010
grpcio==1.62.2
1111
h11==0.14.0
12-
hasura-ndc==0.23
12+
hasura-ndc==0.24
1313
idna==3.7
1414
importlib-metadata==7.0.0
1515
opentelemetry-api==1.24.0

0 commit comments

Comments
 (0)