Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try catch error log stacktrace and continue #168

Open
ComLock opened this issue Aug 24, 2020 · 6 comments
Open

try catch error log stacktrace and continue #168

ComLock opened this issue Aug 24, 2020 · 6 comments
Assignees

Comments

@ComLock
Copy link
Contributor

ComLock commented Aug 24, 2020

Currently I know of no way to log a stacktrace and continue. Please document how, or make it possible ? :)

Related: https://discuss.enonic.com/t/catch-specific-java-errors-in-javascript/928/3

@alansemenov
Copy link
Member

@rymsha any suggestions? has to be implemented?

@rymsha rymsha transferred this issue from enonic/xp Sep 2, 2020
@rymsha rymsha assigned anatol-sialitski and unassigned rymsha Sep 2, 2020
@rymsha
Copy link
Contributor

rymsha commented Sep 2, 2020

This is a documentation issue.
https://github.com/enonic/doc-xp/blob/master/docs/framework/globals.adoc#log

The trick is to provide two arguments where second one is an exception instance:

try {
  bean.run();
} catch (e) {
   log.info('Red Alert!', e)
}

@anatol-sialitski document it, please, since you implemented this improvement.

@ComLock
Copy link
Contributor Author

ComLock commented Sep 2, 2020

So you're saying that if I do:

log.debug(e);
There's no stacktrace in the log

But if I do
log.debug('', e);
Then I get the stacktrace?

@anatol-sialitski
Copy link
Contributor

Yes, by the idea you should be able to log stacktrace if second parameter will be passed as an error/exception.

@ComLock
Copy link
Contributor Author

ComLock commented Sep 7, 2020

What if I want to store the stacktrace in a variable and write it to a Enonic XP node so I can debug errors later? Still sure this is a documentation issue?

@sigdestad
Copy link
Member

You should never store error stack-traces in XP (imagine what might happen), if you intend to store them anywhere, write them to logs.

@alansemenov alansemenov removed their assignment Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants