Coding Duchess
Coding Duchess

Reputation: 6909

Using APEX_ERROR.ADD_ERROR vs RAISE_APPLICATION_ERROR

Can someone explain to me the difference between using APEX_ERROR.ADD_ERROR vs RAISE_APPLICATION_ERROR? What are some drawback of using one vs the other, if any? Or what are the advantages? Is rendering HTML code inside the error message the only advantage of APEX_ERROR.ADD_ERROR? Both seem to display an error message at the top of the page. The only difference, besides rendering HTML, I see is that with APEX_ERROR I can specify the location of the error displayed. Is there something I am missing?

Upvotes: 1

Views: 3606

Answers (2)

david baxter
david baxter

Reputation: 1

It would appear that in the latest APEX versions RAISE_APPLICATION_ERROR in a page process does not display for end users. The error text is only visible to developers. Users see a generic contact support with debug id.

Upvotes: 0

Jeffrey Kemp
Jeffrey Kemp

Reputation: 60262

Although the result looks similar, they are different things with different purposes, so neither has any advantages or drawbacks.

APEX_ERROR.add_error is an APEX API call to allow you to programmatically inject error messages onto the stack for reporting to the user.

RAISE_APPLICATION_ERROR is a PL/SQL command to trigger a custom exception (in hindsight it should probably have been called RAISE_APPLICATION_EXCEPTION to avoid confusion...). Like any PL/SQL exception, if your PL/SQL code doesn't handle it or suppress it, APEX will simply show it to the user like any other error message.

Upvotes: 4

Related Questions