I want to add debugger so how to add that please help?
Server side you can use:
frappe.throw("What went wrong")
or
frappe.log_error("Write this to error log")
And client side you can use:
window.alert("sometext");
or
console.log("got it");
Thank you so much
Thereās also frappe.msgprint('debug message')
for gentler debug prints on the backend.
is it for development or preoduction??
It works for production configuration with developer_mode
enabled. I didnāt test it on the pure production server yet.
ok thanks for the reply
There are instructions how to setup Visual Studio Code to debug: https://github.com/frappe/erpnext/wiki/VSCode-Debugging-for-Frappe-Python
That way you can debug controllers and whitelisted functions. This is not an option (or only a desperate one) for your productive environment.
I also just found out how to debug code started with ābench execute ā¦ā.
This solution uses Visual Studio Code.
Your workspace must be ~/frappe-bench/apps.
Edit your launch.json and add this configuration:
` {
"name": "bench execute",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/frappe/frappe/utils/bench_helper.py",
"args": [
"frappe",
"execute",
"yourapp.yourapp.doctype.yourdoctype.yourdoctype.your_function",
],
"python": "${workspaceFolder}/../env/bin/python",
"cwd": "${workspaceFolder}/../sites",
"env": {
"DEV_SERVER": "1"
}
},
`
This will launch method your_method() in ~/frappe-bench/apps/yourapp/yourapp/doctype/yourdoctype/yourdoctype.py
I found this by try and error. I have no idea what "āenvā: { āDEV_SERVERā: ā1ā } means.
Server side you can use:
frappe.throw("This will throw Error and stop next action")
or
frappe.log_error("Title Here","Write this to error log")
And client side you can use:
window.alert("Alert on Browser");
or
console.log("Get message in browser console");
there is also a frappe.errprint that could be used to print messages to browser console from the controller
frappe.errprint(f"error in query explain: {e}")