Hi Samitha,
If you want to log the full stacktrace in jaggery, you can log it like
below.
log.error(e) //print the stacktrace
log.error('My error message') //print the message
(If you are using the latest jaggery release, it supports logging both
the message and the exception
Hi Praminda,
Thanks for the suggestion. That approach seems suitable here.
Regards.
On Thu, Mar 31, 2016 at 10:33 AM, Praminda Jayawardana
wrote:
> Hi Samitha,
>
> LBYL(Look Bfore You Leap) and EAFP(Easier to Ask Forgiveness than
> Permission) is the two ways used to error checking. Different
Hi Samitha,
LBYL(Look Bfore You Leap) and EAFP(Easier to Ask Forgiveness than
Permission) is the two ways used to error checking. Different languages
have different preferences. Ex: Python prefers EAFP (try-catch) over LBYL
(if-else).
I haven't come across any standard for Java but people use try-
Hi Tharik,
Thanks Tharik. Yes in jaggery level I could detect exception type in catch
block by following your approach. But it seems impossible to log or get the
stack trace of the exception there. But as in the example in yours,
e.javaException.getFaultGateWayString() might be giving it, but not
Hi Samitha,
Backend server should send a proper HTTP Error code instead of return a
value with error message. Here you can throw exception from Java and do the
log in jaggery level. In jaggery level you can detect exception type in
catch block by following approach in the code below.
if(e.javaExc
Hi Sachith,
So do you suppose to catch the error thrown from java, finally at the
jaggery or even later at javascript?
Anyway if we are printing the full stacktrace in Java side, what is the
objective of throwing it to the jaggery ?
Is it to indicate to the front end that an error was occurred in
Hi Samitha,
>From what I understand, you need to both print the full stack trace and
throw a proper message to the front end.
If that so, you can catch the error, log it and throw a custom error from
the java side.
Cheers,
Sachith
On Wed, Mar 30, 2016 at 10:31 AM, Samitha Chathuranga
wrote:
>
Hi,
I am developing a feature in WSO2 PC and in it I have a JavaScript front
end and a Java back end. To call java classes from the JavaScript I am
using Jaggery in between the above two. So my question is what is the best
practice in Exception handling and error logging in such a this scenario.