Error: "Can not find object: use" - chaiscript

I am currently using ChaiScript version 6.0.0 and Visual Studio 2017.
In my C++, I am retrieving a reference to a function on_init() from a script file, and executing it. The ChaiScript object was constructed with the default/empty constructor. The function looks like this:
def on_init() {
use("scripts/test.chai");
}
The contents of "scripts/test.chai" looks like this:
class A {
def A() {
print("Created an instance of A!");
}
}
My file structure looks like this:
bin
\
| my_executable.exe
| scripts
\
| main_menu.chai
| test.chai
When executing the on_init() function shown above, the console prints the following message:
Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use"
Providing "usepaths" when constructing the ChaiScript object results in the same situation.
I have tried use("test.chai") as well as use("scripts/test.chai"), and both result in the same messages.
I am not providing any chaiscript::Options enum on construction of the ChaiScript object, so it should be using the default (which appears to contain External_Scripts as well as Load_Modules).
I am compiling ChaiScript with thread-safety disabled.
I am not having any issues running any of the other built-in functions in this script's body, including in other functions that I am retrieving (into C++) in the same manner as this one.
If there is any more information that is needed, let me know.
Am I using the "use" function incorrectly?

EDIT: Must've been really really high when I wrote the stuff underneath, but I'll leave it there just because I'm astounded I could even come up with that.
The true answer is that you must explicitly pass chaiscript::Options::External_Scripts to the ChaiScript constructor in order to enable the file loading functions.
I do it like so:
class ChaiPlugin
{
public:
/* stuff */
private:
chaiscript::ChaiScript chai = { {}, {}, { chaiscript::Options::External_Scripts } };
};
use is only used for debugging purposes.
from within unittests/boxed_cast_test.cpp:
template<typename T>
void use(T){}
I believe what you're looking for is usefile("scripts/test.chai").

Related

neo4j apoc.export.csv permission denied error

I am trying to use apoc.export.csv
My query is as follows:
call apoc.export.csv.query("MATCH (a) Return id(a) limit 5", "test.csv", {} )
but i get this error:
Failed to invoke procedure 'apoc.export.csv.query': Caused by: java.io.FileNotFoundException: test.csv (Permission denied)
I have the following set in neo4j.conf
apoc.export.file.enabled=true
dbms.security.procedures.whitelist=apoc.export.*
any hints would be appreciated
exporting to /tmp/filename worked!

sails-mysql error handling : TypeError: Converting circular structure to JSON

Server: Sailsjs
Database: mysql
Node Library used: sails-mysql(0.11.5)
I am trying to insert a data in mysql from sailsjs node server.
Data to be inserted:
{
"first_name": "Admin Testing",
"last_name": "User",
"email": "admin14#testing.com",
"role_id": 8
}
Where role_id is having a foreign key relation to model role.
Here the role_id : 8 doesn't have value in role table. So while inserting, it is throwing the error. But that error we couldn't console or json.stringify since the following error occurs:
TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
at /var/www/aitachatbot/server/api/controllers/UserController.js:38:42
at wrapper (/var/www/aitachatbot/server/node_modules/waterline/node_modules/lodash/index.js:3602:19)
at applyInOriginalCtx (/var/www/aitachatbot/server/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/var/www/aitachatbot/server/node_modules/waterline/lib/waterline/utils/normalize.js:331:16)
at error (/var/www/aitachatbot/server/node_modules/switchback/lib/normalize.js:42:31)
at _switch (/var/www/aitachatbot/server/node_modules/switchback/lib/factory.js:56:28)
at /var/www/aitachatbot/server/node_modules/sails-hook-validation/lib/create.js:66:21
at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:223:14
at wrapper (/usr/local/lib/node_modules/sails/node_modules/lodash/index.js:3592:19)
at applyInOriginalCtx (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:335:16)
at error (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:42:31)
at _switch (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:56:28)
at afterwards (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/dql.js:87:16)
at wrapper (/usr/local/lib/node_modules/sails/node_modules/lodash/index.js:3592:19)
at applyInOriginalCtx (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:335:16)
at error (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:42:31)
at _switch (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:56:28)
at sendBackError (/var/www/aitachatbot/server/node_modules/sails-mysql/lib/connections/spawn.js:97:11)
at Object.poolfully [as releaseConnection] (/var/www/aitachatbot/server/node_modules/sails-mysql/lib/connections/release.js:28:12)
at /var/www/aitachatbot/server/node_modules/sails-mysql/lib/connections/spawn.js:90:37
at Query._callback (/var/www/aitachatbot/server/node_modules/sails-mysql/lib/adapter.js:395:27)
at Query.Sequence.end (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
at Query.ErrorPacket (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:94:8)
at Protocol._parsePacket (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:280:23)
at Parser.write (/var/www/aitachatbot/server/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:73:12)
How can we handle this error in sailsjs?
In theory, you don't want these errors to ever show up in production... even if they did, the full json dump of the error object probably is not something a run-of-the-mill user wants to see.
You may also be asking about how to get full info out of this error while debugging. I guess the good news there is, you seem to already know the root cause of your error!
The error objects we have in node can have pretty different structures depending where they come from, but I have yet to encounter an error that does not have smart casting of the errors to strings. That means that even if console.log(err) fails, something like: console.log('Got an error: ' + err) will likely work, casting the error to a string.
The code could be something like this:
User.create({
"first_name": "Admin Testing",
"last_name": "User",
"email": "admin14#testing.com",
"role_id": 8
}).exec(function(err, createdUser) {
if (err) {
var readableErr = '' + err;
console.log('Error creating user: ' + readableErr);
// return something the client will recognize and interpret
// you can use http error codes, or your own conventions
return res.send({
success: false,
message: readableErr
});
}
// do something with createdUser...
});

Missing exception info in NodeJS JSON.parse

In NodeJS, if I let a JSON.parse exception go unhandled and subsequently crash the server, I get an important bit of information outputted to the console.
My JSON:
{
"familyName": "The Flintstones",
"familyContact": {
"fullName": "Wifie Flintstone",
"contact": {
"street1": "1 Granite Ave",
"city": "Bedrock",
"state": "TX",
"postal": "10000"
}
},
this should make it blow up
"patients": [{
"personInfo": {
"fullName": "Wilma Flintstone"
}}, {
"personInfo": {
"fullName": "Fred Flintstone"
}
}
]
}
This is the console output when I let it go unhandled:
undefined:12
this should make it blow up
^
SyntaxError: Unexpected token t
at Object.parse (native)
at Object.exports.uploadPackage.flowUploads.post.flowUploads.write.onDone (/home/ubuntu/workspace/app/controllers/admin/admin.families.server.controller.js:99:27)
at module.exports.$.write.pipeChunk (/home/ubuntu/workspace/app/services/flowUploads.js:173:49)
at Object.cb [as oncomplete] (fs.js:169:19)
but if I catch the exception to prevent the crash, and log like so...
try{
var fileData = JSON.parse(fileText);
}
catch (ex) {
console.log("REASON FOR JSON FAILURE: " + ex, ex.arguments, ex.stack.split("\n"));
}
I get output like this:
REASON FOR JSON FAILURE: SyntaxError: Unexpected token t [ 't' ] [ 'SyntaxError: Unexpected token t',
' at Object.parse (native)',
' at Object.exports.uploadPackage.flowUploads.post.flowUploads.write.onDone (/home/ubuntu/workspace/app/controllers/admin/admin.families.server.controller.js:100:27)',
' at module.exports.$.write.pipeChunk (/home/ubuntu/workspace/app/services/flowUploads.js:173:49)',
' at Object.cb [as oncomplete] (fs.js:169:19)' ]
Missing that key piece of useful info from the crash log that contains the line number and snip of faulty text:
undefined:12
this should make it blow up
^
How I can get to that bit so I can include it in my error messaging?
You can't get that first bit you displayed from the error since it isn't part of the error.
undefined:12
this should make it blow up
^
This is because node is adding that section before dying to show why it died and then shows the error generated by JSON.parse.
To get more detailed messaging you will have to use something other then JSON.parse. As robertklep mentioned you could try greatjson or something similar if getting greater detail on your JSON parsing is important, such as if you are building a service which parses JSON and returns the errors.

Compiler Error Message: CS1009: Unrecognized escape sequence? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
At run-time server error showing in webbrowser regarding Unrecognized escape sequence .
Error Description:
Server Error in '/image11' Application. Compilation Error Description:
An error occurred during the compilation of a resource required to
service this request. Please review the following specific error
details and modify your source code appropriately.
Compiler Error Message: CS1009: Unrecognized escape sequence
Source Error:
Line 21: public void getcon()
Line 22: {
Line 23: con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\MUNDADAN\Documents\..mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
Line 24: con.Open();
Line 25: }
Source File: d:\MY .Net(RuleZZ)\image11\App_Code\Class1.cs Line: 23
Show Detailed Compiler Output:
Show Complete Compilation Source:
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\MUNDADAN\Documents\..mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
This is wrong
Try this
con.ConnectionString = #"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\MUNDADAN\Documents\..mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
or
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\MUNDADAN\\Documents\\..mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";

Gradle error with Android-studio and googleMap api

I created a simple project to test Google Api under android studio , but I have this error I tried to correct it by adding maps.jar to librairies of project structure no way :
Information:Compilation completed with 12 errors and 0 warnings in 17 sec
Information:12 errors
Information:0 warnings
/home/phenix-dz/AndroidStudioProjects/Geolocalisation/Geolocalisation/src/main/java/com/example/geolocalisation/MainActivity.java
Error:Error:line (4)Gradle: error: package com.google.android.maps does not exist
Error:Error:line (5)Gradle: error: package com.google.android.maps does not exist
Error:Error:line (6)Gradle: error: package com.google.android.maps does not exist
Error:Error:line (9)Gradle: error: cannot find symbol class MapActivity
Error:Error:line (11)Gradle: error: cannot find symbol class MapView
Error:Error:line (12)Gradle: error: cannot find symbol class MapController
Error:Error:line (16)Gradle: error: cannot find symbol variable super
Error:Error:line (17)Gradle: error: cannot find symbol method setContentView(int)
Error:Error:line (19)Gradle: error: cannot find symbol class MapView
Error:Error:line (19)Gradle: error: cannot find symbol method findViewById(int)
Error:Error:line (14)Gradle: error: method does not override or implement a method from a supertype
Error:Error:line (25)Gradle: error: method does not override or implement a method from a supertype
also I tried to add this code :
apply plugin: "java"
dependencies {
compile files('/home/phenix-dz/android-studio/sdk/add-ons/google_apis-671458-mac-x86/libs/maps.jar')
}
in build.gradle file but it gives me a same error.
Thanks