error de script de café: sangría inesperada al final de la función

I am trying to make a REST API controller for getting user details in node.js using coffee. Here is my code:

get_get: (req, res, params)->
  @m_auth.can req.user, ['SUPER_USERS_GET'], (err, result)=>
    if err? || !result? || !result
      console.log err
      return res.send 401, { message: constants.auth.no_privs }
    if !params? || !params['username']?
      return res.send 400, { message: constants.params.no_mandatory }
        username: params['username']
    .success (user)->
      .success (privs)->
        user.dataValues.privs = privs
        return res.send 200, user.dataValues
      .error (err)->
        console.log err
        user.dataValues.privs = null
        return res.send 200, user.dataValues
    .error (err)->
      console.log err
      return res.send 500, { message: constants.server.internal_error }

During run it causes error "unexpected indentation" pointing to the last character of the function.

I have double-checked already: all intends are done using white spaces (no tabs).

What might be the reason for this error?

preguntado el 28 de mayo de 14 a las 12:05

As an aside, that code might be easier to read if you replaced the anonymous functions with named ones. -

@muistooshort Thank you for the highlight. I personally hate the syntax of this ORM. It's much easier to work with standard callbacks like callback(err, result) rather than function().success(callback).error(callback). -

1 Respuestas

Stupid mistake! There was a comment right before the function with intend less than a function. I added two spaces and in worked fine.

contestado el 28 de mayo de 14 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.