Hi Mice, It depends on the code that throws the exception. Having shareable exceptions and exception codes makes for more streamlined exception handling than having individual error codes with fixed error messages for every part of the code where an exception is thrown. Embedding the exception message is the approach cloudstack uses. As a thumb rule, the API layer uniformly translates and throws all exceptions as ServerApiException (Alena can provide more info on this in case you have any questions). That is the reason we specify an exception code along with the exception message that a specific part of the mgmt server code fills in. Error codes are not tied to error messages. Error codes are tied only to exceptions as you've already deciphered from the source. The same exceptions can be thrown by different parts of the management server logic, and the exceptions are designed to be as generic (to keep them shareable) and functionally granular as possible. We deliberated the use of having a qualifier alongwith the exception error codes that would tell the user what layer (api/database/management) the exception occurred, but it was felt that it would be unnecessary to pass on this info to the invoking user, since the exception stack trace would be logged to the management server log.
Is there something specific you expected to be able to view in the API response, since you mentioned that the messages were not fine-grained enough? Regards, Vijay ________________________________________ From: Weiran Xia [[email protected]] Sent: Monday, May 28, 2012 6:34 PM To: [email protected] Subject: Re: About cloudstack error messages Hi Nitin, Thanks for your reply. It might not be a particular case. From soruce code, indeed, cloudstack map exception to errorcode, but the error message returned from UI/API is not fine-grained enough to help users narrow down the reason, Now there are about 60 exceptions, which map to 60 errorcode. Does one exception always come up with the same error message (or message format), or it depends on the code which throws it? Regards Mice
