Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Methods to handle error box in Loggable trait #856

fanf opened this Issue Jan 22, 2011 · 2 comments


None yet
3 participants

fanf commented Jan 22, 2011

Baed on the thread here: [[url:https://groups.google.com/d/topic/liftweb/BGCoA9K0mUM/discussion|https://groups.google.com/d/topic/liftweb/BGCoA9K0mUM/discussion]]

It would be nice it logging methods in trait Loggable were aware of the Failure object, as it is a common citizen in Lift based application - in my code, more than exception.

The pattern I met commonly is something looking like:

class MyClass extends Loggable {
  (for { .... sequence of Box }) match {
    case Empty => ...
    case Full(x) => ...
    case f:Failure =>
      logger.error("Error when processing action. Error message: " + f.messageChain)
      f.exception.foreach { e => logger.debug("Exception leading to that error", e)

Of course, it seems that there is a lot of not generic part here (message text, logging level, etc), and so there is a lot of open question about the implementation details.

Moreover, in a lot of my use-cases, Empty is a Failure without message (and not a "no response" one), and in fact, what I am doing is more something like:

class MyClass extends Loggable {
  (for { .... sequence of Box }) match {
    case Full(x) => ...
    case e:EmptyBox =>  //because we don't want to be able to miss an Empty, even if each previous steps of the for loop use "?~!" - it's hard to debug otherwise
      val error = (e ?~! "Error when processing action.") 
      logger.error(  error.messageChain )
      error.exception.foreach { ex => logger.debug("Exception leading to that error", ex)

dpp commented Feb 16, 2011

(In [[r:18d569232ef2c75d135fd7dad73847bb842fe188]]) Closes #856. Makes Box a first class citizen in Loggable
Closes #861. Additional goodies for getting Exceptions from Failure
Ref #886. Makes user agent stuff more flexible

Branch: master

@dpp dpp was assigned Mar 1, 2012

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment