Handle errors and responses appropriately based on the network protocol being used. Different protocols have different mechanisms for error reporting and communication patterns.

For HTTP endpoints:

For WebSockets:

For custom headers: