My organization uses angular 1.2.16. We are using "loginResult.statusText" to print an error message. But the statusText is empty in Win10 but gives the expected output in Win7(statustext is not empty in win7).
loginResult(in win10) is something like this:
I need to understand why statusText prints correct msg in win7 but an empty string in win10. Statustext is empty in chrome and edge of win10. But, statusText contains "Unauthorized"(correct string) in firefox win10
I was trying to print error message
Related
<script type="module" id="user-code">
try {
someUnknownReference;
} catch (error) {
console.log(error) // correct
console.log(error.toString()); // incorrect
console.log(error.stack.toString().split('\n')); // incorrect - line number and filename is wrong
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbImxrc2xrcyJdLCJtYXBwaW5ncyI6IkFBQUFBLE1BQU0iLCJmaWxlIjoiYnVuZGxlLmpzIiwic291cmNlc0NvbnRlbnQiOlsibGtzbGtzIl19
</script>
I'm building a browser based code editor using Babel. All is working well, however I can't for the life of me extract the line number and file name out of the errors that happen during run time.
The example above is a simplified version of what I'm doing. I'm injecting a string into a script tag e.g scriptTag.innerHTML = bundledCode;
The first console.log prints exactly what I want to parse e.g it has the file name and correct line number which it gets from the sourcemap
ReferenceError: someUnknownReference is not defined
at index.js:1
However, as soon as I try to do anything with the error e.g the second console.log, I lose the line number and file name.
ReferenceError: someUnknownReference is not defined
My guess is maybe it's losing the reference to the sourcemap when we try to parse the object?
Thanks in advance for any help!
I think Chrome console is automatically consuming source maps to provide the correct error msg if you're console logging the error. Not if you're grabbing the actual string. Do you need something like this: https://www.npmjs.com/package/sourcemapped-stacktrace?
On React Native log, i always get an error "Unspecified error" or "[object Object]". How get more info about these error?
NB : It's not my variable(and i want to find it). The goal is to know where it is.
Use like this
console.log(JSON.stringify(error)) this will provide error details.
Don't use + sign, use
console.log("error :" , objectWhichYouWantToDisplay)
sign is used for appending strings. That's why you are getting this output on console.
In our application, I am constructing an exception object as under:
auto exception = v8::Object::New(isolate_);
exception->Set(code_name, code_value);
This exception is thrown using the call: isolate_->ThrowException(exception);
On the console and in logs, when we are printing the exception, we see an object instead of exception message. Below is the seen output:
[object Object]
How can we see the exception message as string instead of object?
From Javascript, you can print the exception to the console using JSON.stringify(exception). So your Javascript code would look like this:
try {
...
} catch(err) {
console.log(JSON.stringify(err));
}
You should then see the full object as a String in the console, like this:
{ "message": "An error occurred.", "code": 123 }
With this information, you can easily find the message (and other information) inside the exception object.
From C++, you can also call JSON.stringify():
Handle<Object> json = Context::GetCurrent()->Global()->Get(String::New("JSON"))->ToObject();
Handle<Function> stringify = Handle<Function>::Cast(json->Get(String::New("stringify")));
Then you can call that function with the exception object as a parameter, like this:
stringify->Call(json, 1, exception);
When attempting to run the following code:
try{
document.getElementsByClassName("aklsdjfaskldf")[0].outerHTML;
}catch(err){
alert("Function failed with error dump <"+err.message+">");
}
the error message displayed is truncated:
Function failed with error dump <document.getElementsByClassName(...)[0] is undefined>
Is there a way for the error message to be displayed in full, i.e. display the following message in Firefox? Chrome does not display the output, and therefore is not an issue for my current usage.
Function failed with error dump <document.getElementsByClassName("aklsdjfaskldf")[0] is undefined>
Every browser handles the error call stack differently, if you are on chrome you wont even see that string. It would simply say cannot invoke that outerHTML function on undefined. So better you check the value before invoking a function on that and then show the appropriate alert. Or you print the error.stack if you want to get a hint about the location of the code throwing this error.
I simply want to get the duration of a vimeo video. I don't want to use froogaloop.
The API states: "You interact with the player by sending a serialized JSON object with postMessage() to the . The following format should be used: { "method": "methodName", "value": "value" } Omit the value key if the method requires no value.""
I tried this bit of code:
*$wrapper.find('#parpap')[0].contentWindow.postMessage(JSON.stringify('method', 'getDuration'));*
Firefox tells me: NS_ERROR_XPC_NOT_ENOUGH_ARGS: Not enough arguments [nsIDOMWindow.postMessage]
Chrome tells me: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'.
Safari tells me: [Error] SyntaxError: DOM Exception 12: An invalid or illegal string was specified. fixVideoSize
Anyone got any advice? Thanks. :)
The reason of the errors is that JSON.stringify converts a single value to a json string (either string, number, object or array), you are instead passing to it two strings. What you should do is compose an object like this:
$wrapper.find('#parpap')[0].contentWindow.postMessage(
JSON.stringify(
{
'method': 'getDuration'
}
));
Know more about JSON.stringify on Mozilla Developer Network