Frappe.msgprint and frapp.throw with portal development

Can I use frappe.msgprint and frappe.throw with portal development.If so how can I use the same.I have tried several times with frappe.msgprint but it is not showing anything.Here is the code that I have tried so far

def get_context(context):
frappe.msgprint(
    msg='This file does not exist',
    title='Error',
    raise_exception=FileNotFoundError
)
return context