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

Better error respones from WorkflowInstanceResource endpoints #390

Merged
merged 16 commits into from
Apr 19, 2020

Conversation

efonsell
Copy link
Member

@efonsell efonsell commented Apr 6, 2020

Change nflow-engine to throw IllegalArgumentExceptions instead of IllegalStateExceptions/RuntimeExceptions
Construct error responses with proper HTTP code (400 instead of 500) and message text in WorkflowInstanceResources
Remove ExceptionMapper from nflow-jetty for these cases

@coveralls
Copy link

coveralls commented Apr 14, 2020

Coverage Status

Coverage decreased (-0.1%) to 84.807% when pulling 59042cb on invalid-state-update into 00cc8b9 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 84.898% when pulling ed49384 on invalid-state-update into be52712 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 84.898% when pulling ed49384 on invalid-state-update into be52712 on master.

@efonsell efonsell requested a review from gmokki April 14, 2020 09:59
@efonsell efonsell force-pushed the invalid-state-update branch 2 times, most recently from c49eae4 to f5c62c4 Compare April 18, 2020 21:08
@efonsell efonsell changed the title Trying to update instance state to invalid value should return BAD_REQUEST instead of INTERNAL_SERVER_ERROR Better error respones from WorkflowInstanceResource endpoints Apr 19, 2020
Copy link
Member

@gmokki gmokki left a comment

Choose a reason for hiding this comment

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

This is an api change. We return text/plain from rest apis if an error occurs instead of the previous application/json.
Well actually we do not even test the response content type in the failure tests. But I believe we should keep it at application/json as it was before.

import io.nflow.rest.v1.msg.ErrorResponse;

@Provider
public class StateVariableValueTooLongExceptionMapper implements ExceptionMapper<StateVariableValueTooLongException> {
Copy link
Member

Choose a reason for hiding this comment

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

I think there is a tradeoff between putting the error catching&converting logic to one place vs replicating it in every method of the api.
I think we could have one generic exception mapper that just catches Throwable and returns ErrorResponse object.

@efonsell efonsell requested a review from gmokki April 19, 2020 14:14
@gmokki gmokki merged commit daca838 into master Apr 19, 2020
@gmokki gmokki deleted the invalid-state-update branch April 19, 2020 16:07
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.

None yet

3 participants