Code Monkey home page Code Monkey logo

Comments (4)

ansel1 avatar ansel1 commented on June 19, 2024

I haven't considered it, as we haven't adopted grpc yet. Did you have thoughts on how an extension would look? Were you thinking of WithGRPCCode()/GRPCCode() functions? Would it be appropriate for HTTPCode and GRPCCode functions to interact, using each other for defaults it one or the other isn't set?

from merry.

zhouzhuojie avatar zhouzhuojie commented on June 19, 2024

Maybe it doesn't have to do anything with HTTP codes. For example

import "google.golang.org/grpc/codes"

merry.New("merry error").WithGRPCCode(codes.NotFound)

And internally, it just adds a new errorProperty "grpcCode" to the values, in parallel with httpCode.

from merry.

ansel1 avatar ansel1 commented on June 19, 2024

I looked into this a bit. I don't really want to import grpc into merry. It's a dependency which most projects don't need. I could do WithGRPCCode(uint32) to avoid the import, but I think that would greatly diminish its value.

Also, it looks like it would be useful for errors to implement GRPCStatus() *Status, but again, that can't be implemented without importing grpc.

This could be implemented in its own package, but then, it wouldn't be much effort for you to implement these convenience methods in your own project. merry's Value() and WithValue() functions are intended to be used to implement your own custom error attributes as needed.

from merry.

zhouzhuojie avatar zhouzhuojie commented on June 19, 2024

Thanks, make sense

from merry.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.