node-sdk icon indicating copy to clipboard operation
node-sdk copied to clipboard

Add GRPC Error Details Logging

Open medgar-nitric opened this issue 4 years ago • 0 comments

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.

medgar-nitric avatar Sep 17 '21 00:09 medgar-nitric