1 package body app_exception as
2 /* $Header: AFEXCEPB.pls 120.2 2005/08/19 20:27:05 tkamiya ship $ */
3
4
5
6 --
7 -- PRIVATE VARIABLES
8 --
9
10 -- Exception information
11 exc_type varchar2(30) := NULL;
12 exc_code number := NULL;
13 exc_text varchar2(2000) := NULL;
14
15 --
16 -- PUBLIC FUNCTIONS
17 --
18
19 -- RAISE_EXCEPTION is normally called without any arguments;
20 -- the args here are from legacy but not now used.
21 procedure raise_exception(exception_type varchar2 default null,
22 exception_code number default null,
23 exception_text varchar2 default null) is
24 encoded_text varchar2(4000);
25 return_text varchar2(4000);
26 msg_app varchar2(50);
27 msg_name varchar2(30);
28 msg_number number;
29 msg_num_str varchar2(80);
30 app_str varchar2(255); /* 'APP'*/
31 begin
32 exc_type := exception_type;
33 exc_code := exception_code;
34 exc_text := exception_text;
35
36 if((exception_type is NULL) and
37 (exception_code is NULL) and
38 (exception_text is NULL)) then
39 /* Get the message off the message dict stack, and put it back on*/
40 encoded_text := fnd_message.get_encoded;
41 fnd_message.set_encoded(encoded_text);
42 return_text := fnd_message.get;
43 /* Get the message name to look up the message number */
44 fnd_message.parse_encoded(encoded_text, msg_app, msg_name);
45 msg_number := fnd_message.get_number(msg_app, msg_name);
46 if (msg_number >= 1) then /* If there is a message num, append it */
47 if msg_number <= 99999 then /* Msg num should always <= 5 digits*/
48 msg_num_str := to_char(msg_number, 'FM09999');
49 else /* But just for robustness, don't choke on larger numbers */
50 msg_num_str := to_char(msg_number);
51 end if;
52 app_str := fnd_message.get_string('FND', 'AFDICT_APP_PREFIX');
53 return_text := app_str||'-'||msg_app||'-'||msg_num_str||': '
54 ||return_text;
55 end if;
56 fnd_message.set_encoded(encoded_text);
57 else
58 /* Legacy case */
59 return_text := exc_type||'-'||to_char(exc_code)||': '||exc_text;
60 end if;
61
62 if (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
63 FND_LOG.STRING(FND_LOG.LEVEL_EXCEPTION,
64 'fnd.plsql.APP_EXCEPTION.RAISE_EXCEPTION.dict_auto_log', return_text);
65 end if;
66
67 -- raise_application_error message should be <= 512 bytes
68 return_text := substrb(return_text, 1, 512);
69
70 /* Raise the application error and put the message text on the */
71 /* OCI buffer so it will display if called from SQL*Plus. */
72 raise_application_error(-20001, return_text);
73 end raise_exception;
74
75 procedure get_exception(exception_type OUT NOCOPY varchar2,
76 exception_code OUT NOCOPY number,
77 exception_text OUT NOCOPY varchar2) is
78 begin
79 exception_type := exc_type;
80 exception_code := exc_code;
81 exception_text := exc_text;
82 end get_exception;
83
84 function get_type return varchar2 is
85 begin
86 return exc_type;
87 end get_type;
88
89 function get_code return number is
90 begin
91 return exc_code;
92 end get_code;
93
94 function get_text return varchar2 is
95 begin
96 return exc_text;
97 end get_text;
98
99 procedure invalid_argument(procname varchar2,
100 argument varchar2,
101 value varchar2) is
102 begin
103 fnd_message.set_name('FND', 'FORM_INVALID_ARGUMENT');
104 fnd_message.set_token('PROCEDURE', procname);
105 fnd_message.set_token('ARGUMENT', argument);
106 fnd_message.set_token('VALUE', value);
107 app_exception.raise_exception;
108 end invalid_argument;
109
110 end app_exception;