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

CHE-1232. Add mapper for RuntimeException #1547

Merged
merged 8 commits into from
Sep 12, 2016
Merged

CHE-1232. Add mapper for RuntimeException #1547

merged 8 commits into from
Sep 12, 2016

Conversation

RomanNikitenko
Copy link
Member

The mapper will allow to get readable error messages on client side for RuntimeException
@vparfonov please review

Signed-off-by: Roman Nikitenko rnikitenko@codenvy.com

@benoitf
Copy link
Contributor

benoitf commented Jun 22, 2016

do we have a test checking these runtime exceptions are correctly handle (so that a mapper does the job) ?

public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
@Override
public Response toResponse(RuntimeException exception) {
String errorMessage = exception.getMessage();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findbug usually recommends usage of getlocalizedmessage instead of getMessage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, fixed

@garagatyi
Copy link

@benoitf I suppose it is hard to test such thing because it require Everrest. And to make it really reliable it should launch whole Che server.

@garagatyi
Copy link

@skabashnyuk Please take a look

@benoitf
Copy link
Contributor

benoitf commented Jun 22, 2016

@garagatyi AFAIK EverrestJetty.class listener allow to test REST components and we already test some filters, REST Service, etc so I don't see the issue of being hard to be tested ?

@skabashnyuk
Copy link
Contributor

EverrestJetty can handle that I think.

@garagatyi
Copy link

LGTM

public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
@Override
public Response toResponse(RuntimeException exception) {
String errorMessage = exception.getLocalizedMessage();
Copy link
Member

@sleshchenko sleshchenko Jun 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to log this error because we should not throw RuntimeException in services at all and usually it is possible in case of bug
@garagatyi @skabashnyuk @vparfonov WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codenvy-ci
Copy link

Build # 983 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/983/ to view the results.

@benoitf
Copy link
Contributor

benoitf commented Jun 23, 2016

I still don't see this server code being tested ?

@skabashnyuk
Copy link
Contributor

-1 to merge it without test

@RomanNikitenko
Copy link
Member Author

@benoitf @skabashnyuk I don't merge it. I need to finish my current issue, so - don't worry - I will do it :-)

public Response toResponse(RuntimeException exception) {
String errorMessage = exception.getLocalizedMessage();
if (!isNullOrEmpty(errorMessage)) {
LOG.error(errorMessage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that LOG.warn(errorMessage, exception); would be better. And put it before check

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that LOG.error(errorMessage, exception)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for log error with stacktrace. RuntimeException here means bug in code, so we should findout how to fix that ASAP and stacktrace will definitely help

@codenvy-ci
Copy link

@codenvy-ci
Copy link

Build finished.
Build success. $BUILD_URL

@codenvy-ci
Copy link

@skabashnyuk
Copy link
Contributor

@benoitf FYI server code is tested

@garagatyi
Copy link

LGTM

LOG.error("RuntimeException occurred", exception);
}

return Response.serverError().build();
Copy link
Member

@sleshchenko sleshchenko Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mb it would be better to send ServiceError with default message to avoid writing client side's logic for expecting service error or empty body ?

@codenvy-ci
Copy link

Build # 73 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/73/ to view the results.

@RomanNikitenko
Copy link
Member Author

I've updated pull request
User will get error message in the next format when RuntimeException occured:
runtimeexception

@codenvy-ci
Copy link

Build # 106 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/106/ to view the results.

@skabashnyuk
Copy link
Contributor

ok

1 similar comment
@vparfonov
Copy link
Contributor

ok

@codenvy-ci
Copy link

Build # 131 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/131/ to view the results.

@garagatyi
Copy link

@skabashnyuk @vparfonov @riuvshin Can we merge it now?

@codenvy-ci
Copy link

@skabashnyuk
Copy link
Contributor

ok

@garagatyi garagatyi merged commit 543eeb4 into master Sep 12, 2016
@garagatyi garagatyi deleted the CHE-1232 branch September 12, 2016 13:02
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
Signed-off-by: Roman Nikitenko <rnikitenko@codenvy.com>
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

Successfully merging this pull request may close these issues.

7 participants