GithubHelp home page GithubHelp logo

Comments (4)

thijsc avatar thijsc commented on July 26, 2024

Good point, these two use cases should be possible in a nice way. We're going to look at this and see if we can find a good solution.

from appsignal-ruby.

matsimitsu avatar matsimitsu commented on July 26, 2024

listen_for_exception and send_exception were originally meant to track exceptions in rake tasks (or background jobs) .
It sounds like a good idea to have a way to track an exception within an request.

In the meantime you can try the following
(if you are willing to play with Appsignal internals, also i didn't test this :))

class PushNotification < ApplicationController
  rescue_from Exception, with: :render_error

  def update
    # do the magic that may throw an exception
    respond_to do |format|
      format.json { render text: '', status: 200 }
      format.html { render text: '', status: 200 }
    end
  end

private
  def render_error(exception=nil)
    # Transaction.current checks if we have an active transaction (e.g. Rails request) 
    # and add_exception adds an exception to the request/transaction
    if exception && Appsignal::Transaction.current
      Appsignal::Transaction.current.add_exception(exception) 
    end

    respond_to do |format|
      format.json { render text: '', status: 200 }
      format.html { render text: '', status: 200 }
    end
  end
end

from appsignal-ruby.

matsimitsu avatar matsimitsu commented on July 26, 2024

@thijs we should probably make this available on the Appsignal module

from appsignal-ruby.

thijsc avatar thijsc commented on July 26, 2024

We shipped this today in version 0.6.6 of the gem, info on how to use it: http://docs.appsignal.com/tweaks-in-your-code/handle-exceptions.html#toc_5

@brickattack Could you try this out and let us know if it works for you?

from appsignal-ruby.

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.