How to get error message in NativeScript 5? - nativescript

Could help me. How to get Error message in NativeScript 5 ?
try {
devices = getDeviceList();
} catch (error) {
console.log(error.message);
}
This code write to console
'org.nativescript.b360124.serailport.NSSerialport$NSSerialPortException:
Device not found! JS:
org.nativescript.b360124.serailport.NSSerialport.getDeviceList(NSSerialport.java:66)
JS: com.tns.Runtime.callJSMethodNative(Native Method) JS:
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120) JS:
com.tns.Runtime.callJSMethodImpl(Runtime.java:1000) JS:
com.tns.Runtime.callJSMethod(Runtime.java:987) JS:
com.tns.Runtime.callJSMethod(Runtime.java:967) JS:
com.tns.Runtime.callJSMethod(Runtime.java:959)
And how get message "Device not found!", Thanks.

Related

Nativescript and SignalR?

I’m developing an app using NativeScript + Angular and need it to have a SignalR connection. I'm using nativescript-signalr-core plugin to connect my app with the signalR. The server side project is written by asp.net core 3.1 (this link).
According to the instructions of plugin, I want to connect to the server, it connects the first moment but it is disconnected immediately.
This is my typescript code:
connectToServer_Core() {
this.signalrCore.start(this.hubUrl).then((isConnected: boolean) => {
console.log('isConnected? ', isConnected);
console.log('status: ' + JSON.stringify(this.signalrCore.getStatus()));
})
.catch(error => {
console.error(error.message);
});
}
This is the output of the function execution:
JS: isConnected? true
JS: status: {"id":2,"name":"Socket Opened"}
JS: disconnected
JS: Unhandled Promise rejection: Error - Connection already close! ; Zone: <root> ;
Task: setTimeout ; Value: Error - Connection already close! undefined
This is the output after invoke():
JS: status: {"id":2,"name":"Socket Opened"}
JS: ERROR Error: Uncaught (in promise): Error - socket is not connected
Please help me how to solve this problem?

Problem with Nativescript 7 angular 8 and nativescript-google-maps-sdk

I'm facing this error when trying to dislay google maps on android emulator, using nativescript 7.2.0 Angular 8 and nativescript-google-maps-sdk 3.0.2 :
JS: ERROR Error: Uncaught (in promise): TypeError: nativescript_core__WEBPACK_IMPORTED_MODULE_1_.Property is not a constructor
JS: TypeError: nativescript_core__WEBPACK_IMPORTED_MODULE_1_.Property is not a constructor
JS: at Module.../node_modules/nativescript-google-maps-sdk/map-view-common.js (file: node_modules\nativescript-google-maps-sdk\map-view-common.js:275:7)
JS: at webpack_require (file: src\webpack\bootstrap:750:0)
JS: at fn (file: src\webpack\bootstrap:120:0)
JS: at Module.../node_modules/nativescript-google-maps-sdk/map-view.js (file: node_modules\nativescript-google-maps-sdk\map-view.android.js:1:0)
JS: at webpack_require (file: src\webpack\bootstrap:750:0)
JS: at fn (file: src\webpack\bootstrap:120:0)
JS: at Module../app/home/home.component.ts (file: src\app\home\home.component.ts:1:0)
JS: at webpack_require (f...
If anyone can help
Thank you
You may want to check out the issues on the nativescript-google-maps-sdk github site, particularly this one.

How to fix 'TypeError: this.isCallback is not a function' error for UserAgentApplication in msal.js

using Msal v1.0.2, loginPopup is not working from iFrame.
trying to get the UserAgentApplication instance using client_id. its throwing an exception:
TypeError: this.isCallback is not a function
at Object.UserAgentApplication (UserAgentApplication.ts:228)
const myMSALObj = Msal.UserAgentApplication(msalConfig);
myMSALObj.loginPopup(["user.read"]).then(function (loginResponse) {
return myMSALObj.acquireTokenSilent(accessTokenRequest);
}).then(function (accessTokenResponse) {
const token = accessTokenResponse.accessToken;
}).catch(function (error) {
//handle error
});
sample from . 'Quickstart for MSAL JS' works fine but when I try to integrate Msal inside iFrame of my JavaScript plugin code, its not working.
working code from sample:
var myMSALObj = new Msal.UserAgentApplication(msalConfig);
myMSALObj.handleRedirectCallback(authRedirectCallBack);
myMSALObj.loginPopup(requestObj).then(function (loginResponse) {
acquireTokenPopupAndCallMSGraph();
}).catch(function (error) {
//Please check the console for errors
console.log(error);
});
there was a typo causing this exception: TypeError: this.isCallback is not a function at Object.UserAgentApplication (UserAgentApplication.ts:228)
fix: const myMSALObj = new Msal.UserAgentApplication(msalConfig);
That should solve this exception issue.

Axios catch will not trigger

I have a react app that the user will enter info into a redux form and the function is called. I have a axios post that will not catch an error. I'm not sure what this is happening.
export function vehicleformsubmit(props){
const input={
rfidtag: rfidtag.value,
vin: vin.value,
vehzone: vehzone.value
};
var request=axios.post(`http://localhost:9000/api/bmwvehicle/create`, input);
return function(dispatch){
request.then((response) =>{
dispatch(createVehicleSuccess(response.data, response.status));
}).catch((error) =>{
if(error.response){
dispatch(vehicleHaveError(true));
}
});
};
}
This is that I get back:
createError.js:16 Uncaught (in promise) Error: Request failed with
status code 500
at createError (createError.js:16)
at settle (settle.js:18)
at XMLHttpRequest.handleLoad (xhr.js:77)

Giving Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template

This is my code and it is giving error
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error
in template "C:\wamp\www\pangu\application\views\front\employer\lesson\topic_popup.tpl" on line 89
"$.post("{site_url()}("employer/library/show_topic");",{"id":id,"sts":sts},function(responseText){" - Unexpected ":", expected one of: "}" , " " , ATTR'
in C:\wamp\www\pangu\application\third_party\Smarty-3.1.13\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 665
i am new in smarty
<script>
function show_topic(id,sts){
if($('#ch_'+id).is(":checked")) {
sts =1;
}
else{
sts = 0;
}
$.post("{site_url()}("employer/library/show_topic");"{"id":id,"sts":sts},function(responseText){});}
</script>
use {literal} after open function() eg:
function init_map(){
{literal}
scripts
{/literal}
}
It seems that's problem you have Javasript in your Smarty template.
You should do it in this way:
<script type="text/javascript"?
{literal}
// here you can put your javascript code safely
{/literal}
</script>
However in some cases it's not necessary to use them - look at http://www.smarty.net/docs/en/language.function.literal.tpl

Resources