sql server - MSNodeSQL query error results or misunderstanding of JavaScript variables -


When an MSNodeSQL query fails, I'm confused with callback arguments. I am new to JavaScript, so this is a simple JavaScript Problems can be there. The database is a simple query:

  conn.query (stored procedure, parameter, function (error, result) {if (err) {console.log ("err =" + err); Console Log ("err =" + JSON.stringify (mistake));}});  

I have given the name of a stored procedure, so it will not be found and an error will be compelled. The logic of the error shows a meaningful description of the error:

  err = Error: [Microsoft] [SQL Server Native Client 11.0] [SQL Server] stored procedure 'dbo.me3_MsgQueueIn_AddMessage'.  

When I return this variable to the customer and show it in a browser which it appears as a JSON object and when I display it on the server as shown above , Then it is a JSON object and I see

  err = {"sqlstate": "42000", "code": 2812}  

Such a typical error code is also good for a meaningful description of the error.

Can anyone explain how to accidentally have two values, string, and JSON objects?

Second, how can I see the meaningful explanation in the browser on the client, because at present I only look at the JSON object with my two areas.

What you are seeing is a customized error that is used by the ISLL package. Error object is not exactly a JSON object like the other What is included in the error JSON.stringify

is not shown in, Take this code as an example:

  function custom order (msg) {var err = Error.call (this, msg); Err.customField = "abc"; Return fault; } Var err = new error ("bad thing"); Console.log ("err =" + err); Console.log ("err =" + JSON.stringify (mistake)); Var customErr = new custom error ("custom bad thing"); Console.log ("customErr =" + customErr); Console.log ("customErr =" + JSON.Stringify (CustomRar));  

which gives output like this:

  err = error: bad thing err = {} customErr = error: custom bad thing customErr = {" CustomField ":" ABC "}  

As you can see, the customized error is only visible to the field that is defined for it, which is returned to JSN The object is.

There are also interesting properties of errors!

name error type is the custom error definition for err.name = "CustomError"; Try adding to it will convert the product to "customErr = custom error : custom boot thing" (Zor Khan).

Want to see that error message on your customer? Try err.message , which is everything after the name This string is used on the creation of an error.

A fun one is the stack property, which prints the error stack trace. Do not send it to your client :) It is also that you have got an error, and have not been caught. Provide custom ARR; Try one (though note that the node process will stop).


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -