node-sdk
node-sdk copied to clipboard
Add GRPC Error Details Logging
Add logging of GRPC Error Details.
Nitric Service errors now return structured error information to help developers debug code and operational staff support applications. An example error report from the Membrane via the Java SDK Faas is provided below:
SEVERE: error handling Trigger HTTP GET '123' with com.example.service.ReadFunction
io.nitric.api.NotFoundException[
code: NOT_FOUND
message: document not found
cause: not found
service: DocumentService.Get
plugin: BoltDocService.Get
args: {key={Collection: {Name: example, Parent: <nil>}, Id: 123}}
]
at io.nitric.api.NitricException.build(NitricException.java:256)
at io.nitric.api.document.DocumentRef.get(DocumentRef.java:86)
at com.example.service.ReadFunction.handle(ReadFunction.java:23)
at io.nitric.faas.Faas$FaasStreamObserver.onNext(Faas.java:204)
The new error types are provided at: https://github.com/nitrictech/nitric/blob/develop/contracts/proto/error/v1/error.proto
message ErrorScope {
// The API service invoked, e.g. 'Service.Method'.
string service = 1;
// The plugin method invoked, e.g. 'PluginService.Method'.
string plugin = 2;
// The plugin method arguments, ensure only non-sensitive data is specified.
map<string, string> args = 3;
}
message ErrorDetails {
// The developer error message, explaining the error and ideally solution.
string message = 1;
// The error root cause.
string cause = 2;
// The scope of the error.
ErrorScope scope = 3;
}
See https://grpc.io/docs/guides/error/ for additional information.