Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » How to send an error? (HTTP 400)
How to send an error? (HTTP 400) [message #458159] Thu, 27 May 2010 11:08 Go to next message
spiff
Messages: 2
Registered: May 2010
Junior Member
When an input parameter to a procedure is bad, I'd like to send an HTTP 400 error back to the user with a useful error message.

How do I generate a 400 error from mod_plsql?

All the examples I have seen show how to return nicely formatted HTML, presumably with a status code 200. When I get an exception in my procedure, I'd like to return an error code to the client so that the client doesn't try to parse the content as if it were valid data.

-s
Re: How to send an error? (HTTP 400) [message #461842 is a reply to message #458159] Mon, 21 June 2010 15:09 Go to previous messageGo to next message
spiff
Messages: 2
Registered: May 2010
Junior Member
The correct answer is to use a couple OWA_UTIL functions that manipulate the HTTP header before returning content for the browser:

    owa_util.status_line(l_status_code, l_message, false);
    owa_util.mime_header(l_mime_type, true, C_HTTP_CHARSET);


or:

    owa_util.status_line(400, 'myapp(): helpful error message here', false);
    owa_util.mime_header('application/json', true, 'ISO-8859-4');
    htp.p('this is page content here')


[Updated on: Mon, 21 June 2010 15:10]

Report message to a moderator

Re: How to send an error? (HTTP 400) [message #461846 is a reply to message #461842] Mon, 21 June 2010 16:07 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
Thanks for the update
Previous Topic: How get Current user group information
Next Topic: Multi column LOV in Apex
Goto Forum:
  


Current Time: Mon Aug 03 10:46:01 CDT 2020