Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error not catched #34

Closed
JXBAR opened this issue Feb 21, 2014 · 6 comments
Closed

Error not catched #34

JXBAR opened this issue Feb 21, 2014 · 6 comments

Comments

@JXBAR
Copy link

JXBAR commented Feb 21, 2014

Hi, i dont know where to put my message so i'll just write it there.
I've read a lot about your very interesting plugin but i just cant get it work properly.
I threw my exception in the try function, and handle it on the catch callback.The nodejs process just crash.

exports.newTag = function(req,res)
{
  trycatch(function()
  {
    var label = req.body.label;
    if(!label)
    {
      var error = new Error("Veuillez entrer un label pour le tag");
      error.custom = true;
      throw error;
    }
    database.Tag.count({label:label},function(err,count)
    {
      if(err) throw err;
      if(count> 0)
      {
        var error = new Error("Le tag existe déjà, entrez un autre nom");
        error.custom = true;
        throw error;
      }

      var tag = 
      {
        label: label
      };
      tag = new database.Tag(tag);
      tag.save(function(err)
      {
        if(err) throw err;
        return res.json({ok:true,tag:tag});
      });

    })

  },function(err)
  {
    console.error(err.stack);
    if(err.custom)
    {
      return res.json({ok:false,msg:error.message});
    }
    return res.json({ok:false,msg:"Désolé, une erreur est survenue"}); 
  });
 }
@CrabDude
Copy link
Owner

Your code looks good.

What package/module is "database"?
Could you try and reduce your code to the minimum reproducible case?

Also, please add the following to your code and paste the output here:

process.on('uncaughtException', function(err) {
  console.log(err.stack);
});

@CrabDude
Copy link
Owner

Any update?

@JXBAR
Copy link
Author

JXBAR commented Mar 19, 2014

Hi,
I'm sorry i didn't post sooner . I am now reducing the code to the minimum and i will post it as soon as possible.
Thanks.

@CrabDude
Copy link
Owner

CrabDude commented Apr 2, 2014

Try the latest version v1.5.4. There's a lot of refinements and improvements I've made to the code since you filed this bug (around v1.0.6). I suspect if you have an issue, it's very likely it's been fixed.

@CrabDude
Copy link
Owner

Any update? =)

@CrabDude
Copy link
Owner

CrabDude commented Sep 1, 2015

Closing. Let me know if you are able to reproduce.

@CrabDude CrabDude closed this as completed Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants