-
When using the @CloudFunction()
Future<void> function(PubSub pubSub, RequestContext context) async {
//... How can I return specific Http status codes? I've tried setting Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Thoughts @subfuzion and @grant ? |
Beta Was this translation helpful? Give feedback.
-
If you throw a random error it will end up sending a 500. And I think there
is an exception type that if you throw it means that it was endowed request
and will return a 400 type. I'm away from my keyboard right now, so I'll
have to look
β¦On Sat, Aug 14, 2021, 12:40 Grant Timmerman ***@***.***> wrote:
https://github.com/GoogleCloudPlatform/functions-framework#http-status-codes
For event-driven functions, we usually keep the interface minimal to cover
CloudEvent semantics and not HTTP semantics. The framework will return 200
if nothing goes wrong. 4XX if the function throws an error, etc. You can
always use the HTTP signature and inspect headers / return JSON.
Returning nothing or a CloudEvent is usually OK.
β
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#271 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEFCUVN4SCZVCJ4EVVBF3T42TARANCNFSM5CDMU2DA>
.
|
Beta Was this translation helpful? Give feedback.
-
Here you go: https://pub.dev/documentation/functions_framework/latest/serve/BadRequestException-class.html Through this to send a |
Beta Was this translation helpful? Give feedback.
Here you go: https://pub.dev/documentation/functions_framework/latest/serve/BadRequestException-class.html
Through this to send a
400
β other exceptions send a500