GithubHelp home page GithubHelp logo

Comments (3)

NZKoz avatar NZKoz commented on June 8, 2024

So my work around implementation looks like this.

        try {
            RaygunMessage message;
            message = RaygunServletMessageBuilder.New()
                    .SetRequestDetails(request)
                    .SetEnvironmentDetails()
                    .SetMachineName(InetAddress.getLocalHost().getHostName())
                    .SetExceptionDetails(throwable)
                    .SetClientDetails()
                    .Build();
            this.executor.execute(new SubmitExceptionCommand(client, message));
        } catch (UnknownHostException e) {
            // error when handling errors, not much to do but log and fail
            e.printStackTrace();
        }
// 
    private final class SubmitExceptionCommand implements Runnable {
        public SubmitExceptionCommand(RaygunClient client, RaygunMessage message) {
            this.client = client;
            this.message = message;
        }
        private final RaygunClient client;
        private final RaygunMessage message;
        @Override
        public void run() {
            client.Post(message);
        }
    }

Three things are slightly annoying.

  1. I can't get the builder out of the client without duplicating the code. Something like .messageBuilderForException( would help.
  2. I can't add the servlet request to a non servlet client's builder,
  3. The Servlet builder should return specific subclasses in its methods, because you have to call .SetRequestDetails(request) first or it won't work

from raygun4java.

fundead avatar fundead commented on June 8, 2024

Just to clarify:

  1. messageBuilderForException() should take a Throwable, call RaygunServletMessageBuilder.New().SetRequestDetails()...Build() (with all the various parts of the message set, request, env, machineName etc), then return the resulting RaygunMessage? Or just call .New()?
  2. This should be by design as core.RaygunClient is built without the reference to javax.servlet.http.HttpServletRequest, as otherwise non-web projects would need to have a server on their classpath, or import the Maven deps even if they weren't otherwise used. The RaygunServletClient specifically does have this dependency (and the Play 2 client has its own Request object reference yet again) as it is used.
    The non-servlet core.RaygunClient has no concept of web requests for that reason, to avoid the dependency - if this seems wrong let me know.
  3. Just modified BuildServletMessage quickly to test this:
RaygunServletMessageBuilder.New()
            //.SetRequestDetails(servletRequest)
            .SetEnvironmentDetails()
            .SetMachineName(InetAddress.getLocalHost().getHostName())
            .SetExceptionDetails(throwable)
            .SetClientDetails()
            .SetVersion(_version)
            .SetUser(_user)
            .Build();

and that builds and sends the RaygunMessage as expected without setting the request at all. The New() instantiates the RaygunServletMessageBuilder, the inherited methods set their props then Build() sets and returns the final RaygunServletMessage so as long as New()'s called first and Build() last this should work - might be a different scenario I haven't repro'd here.

from raygun4java.

mduncan26 avatar mduncan26 commented on June 8, 2024

Closing this issue for now. If you wish to see this issue addressed please create a new issue or post within our forums (https://raygun.com/forums). Thank you.

from raygun4java.

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.