Giter Club home page Giter Club logo

Comments (4)

didimitrie avatar didimitrie commented on August 15, 2024 1

The democratic consensus above is that we'll clean that up so we can do throw new SpeckleException( ... ) instead of Log.CaptureAndThrow(), so it stays open :D

The SpeckleException class will have multiple constructors covering any cases we might want to wrap around.

TBH, it's my fault - we discussed the Log.CaptureAndThrow() approach in the past when you've implemented it, but I wasn't awake enough to catch it in time...

from speckle-sharp.

didimitrie avatar didimitrie commented on August 15, 2024

Yep, the extra doesn't seem to be carried over in the exception here:
https://github.com/specklesystems/Core/blob/25c08e7e3fd3232b1d20b466a7c8f5330d59c4bb/Core/Logging/Log.cs#L67-L76

I also feel like - this might be a bikeshed design moment - it would be a bit more natural to invert the ops a bit. What do i mean by this:

  • in code, just throw new SpeckleException( ... )s - which can be constructed from GQL errors, like above, or from normal exceptions
  • in the constructors, do a Log.Capture( ... )

This would change this:

https://github.com/specklesystems/Core/blob/25c08e7e3fd3232b1d20b466a7c8f5330d59c4bb/Core/Api/Client.GraphqlClientOperations.cs#L40-L49

to

 public async Task<User> UserGet()
    {
      try
      {
        var request = new GraphQLRequest
        {
          Query = etc
        };

        var res = await GQLClient.SendMutationAsync<UserData>(request);

        if (res.Errors != null)
          throw new SpeckleException( res.errors );

        return res.Data.user;
      }
      catch (Exception e)
      {
         throw new SpeckleException( e );
      }
    }

from speckle-sharp.

izzylys avatar izzylys commented on August 15, 2024

I like this idea! Feels more natural to be throwing a SpeckleException rather than faffing with capturing and throwing. imho easier to use and cleaner to read ✨

from speckle-sharp.

teocomi avatar teocomi commented on August 15, 2024

Okay, this should be fixed with: ee3edc9#diff-76acbbd665fda0e26440acdb0d57074b4183fe02631e41b17bc9d7aebd2d83ebR52

It's now returning the first gql error. Initially I had standardized on predefined error messages to be able to group these exceptions in Sentry. Feel free to close @didimitrie

from speckle-sharp.

Related Issues (20)

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.