Uncaught Server Exception within Cart View

Please assist, I have an error when using the Cart on the Hosted Version (currently on Trial). I have tried this on two separate installations, and when the cart is populated I get the same error.

Is this going to be fixed in the next update?

Thanks for posting - please could you copy and paste the complete traceback?

Screen grabs make it not so easy to dig into the code…

Possibly but that depends, updates often occur daily.

Welcome to ERPNext!

Traceback (most recent call last):
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/website/render.py”, line 45, in render
data = render_page_by_language(path)
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/website/render.py”, line 142, in render_page_by_language
return render_page(path)
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/website/render.py”, line 158, in render_page
return build(path)
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/website/render.py”, line 165, in build
return build_page(path)
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/website/render.py”, line 181, in build_page
html = frappe.render_template(context.source, context)
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/utils/jinja.py”, line 75, in render_template
return get_jenv().from_string(template).render(context)
File “/home/frappe/benches/bench-2019-01-23/env/lib/python2.7/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/home/frappe/benches/bench-2019-01-23/env/lib/python2.7/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “”, line 1, in top-level template code
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/./templates/web.html”, line 6, in top-level template code
{%- if page_or_generator==“Generator” %}source-type=“Generator” data-doctype=“{{ doctype }}”{% endif %}
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/./templates/base.html”, line 37, in top-level template code
{% block body %}
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/./templates/base.html”, line 63, in block “body”
{% block content %}{% endblock %}
File “/home/frappe/benches/bench-2019-01-23/apps/frappe/frappe/./templates/web.html”, line 49, in block “content”
{%- block page_content -%}{%- endblock -%}
File “”, line 42, in block “page_content”
File “/home/frappe/benches/bench-2019-01-23/apps/erpnext/erpnext/./templates/includes/cart/cart_items.html”, line 29, in top-level template code
_(“Rate: {0}”).format(d.get_formatted(“rate”)) }}


UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa3’ in position 0: ordinal not in range(128)

Thanks!

Some additional info please, when and where do you get the error -

Please post a screenshot of the shopping cart render view just before the error occurs. Say when you Click on “Add to Cart” to add item to shopping cart?

The UnicodeError arises since a non-ASCII character appears for the rate value - ASCII is the default encoding in Python.

Another idea -

The problem is with position 0, so maybe the currency symbol is the problem!?
In which case in Global Defaults ‘Hide Currency Symbol’ to hide the symbol might point to the problem?

I myself am not familiar with the shopping cart

edit: Possibly a setup problem but probably best report this on Issues · frappe/erpnext · GitHub

If you are curious here are two worthwhile reads on encodings:

Unicode HOWTO — Python 2.7.18 documentation

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) – Joel on Software

Hi John

Hiding the currency symbol solved the issue.

Many thanks

Excellent news thanks

Reported here for the record [erpnext.com hosted] Shopping cart UnicodeError on Item rate due to Currency Symbol · Issue #16517 · frappe/erpnext · GitHub

My guess is this error will resolve itself once erpnext.com moves to Python 3.

I was not sure whether to post a new topic, but I got a similar error “Uncaught server exception” in the shopping cart. I removed the currency symbol from the global defaults, but that did not fix the issue. Attached below is the traceback code. Can someone help? Thanks.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py”, line 50, in render
data = render_page_by_language(path)
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py”, line 177, in render_page_by_language
return render_page(path)
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py”, line 193, in render_page
return build(path)
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py”, line 200, in build
return build_page(path)
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py”, line 223, in build_page
html = frappe.get_template(context.template).render(context)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/jinja2/environment.py”, line 1090, in render
self.environment.handle_exception()
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/jinja2/environment.py”, line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/jinja2/_compat.py”, line 28, in reraise
raise value.with_traceback(tb)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/./templates/pages/order.html”, line 2, in top-level template code
{% from “erpnext/templates/includes/order/order_macros.html” import item_name_and_description %}
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/web.html”, line 1, in top-level template code
{% extends base_template_path %}
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/base.html”, line 66, in top-level template code
{{ banner_html or “” }}
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/web.html”, line 56, in block “content”


File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/jinja2/sandbox.py”, line 462, in call
return __context.call(__obj, *args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/jinja2/runtime.py”, line 679, in _invoke
rv = self._func(*arguments)
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/web.html”, line 15, in template
{% block page_container %}
File “/home/frappe/frappe-bench/apps/frappe/frappe/./templates/web.html”, line 29, in block “page_container”

File “/home/frappe/frappe-bench/apps/erpnext/erpnext/./templates/pages/order.html”, line 45, in block “page_content”
{{ frappe.utils.formatdate(doc.transaction_date, ‘medium’) }}
File “/home/frappe/frappe-bench/env/lib/python3.7/site-packages/jinja2/sandbox.py”, line 462, in call
return __context.call(__obj, *args, **kwargs)
TypeError: ‘NoneType’ object is not callable