-
Notifications
You must be signed in to change notification settings - Fork 156
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
ErrorCode on BadRequest on client side #366
Comments
that utf8 thing will dissappear. Just today a ticket was created. I suspect the BadRequestException has a higher priority. You should inherit from that one. Then it probably works. Need to clear that up in the docs. |
(in other areas I started introducing priorities) |
I guess priorities for exception mappers would be a good idea. I just noticed that ExceptionMapperFactory prefers mappers that handle exception that are deeper in the type hierarchy which does not really make sense for me. Extending from BadRequestException will probably solve my problem, but by doing so I dont even need to implement an exception mapper. This is OK for my usecase but what if third party libraries throw exceptions (that do not extend from Crnk exceptions) or you simple do not want to extend from one of the crnk exceptions because the class that throws the exception does not reside in your rest layer? Furthermore: Is there a reaseon why CrnkExceptionMapper does not pass the ErrorData object to the exceptions he instantiates? And why does e.g. BadRequestException offer constructors that accept http status codes? It seems like the exception handling mechanism still needs some tuning. Do you agree? Can I help you out on those issues? |
yes, the constructors need stream-lining, that did not really change this past year. I considered a number of times touching it. So far it is unmodified from Katharsis behavior I think. There is already a Prioritizable interface that could be used. There are some first places where it is applied, but it should be applied everywhere. if you have time, PRs would be great. We can also discuss changes further. |
@remmeier I've recently run across the same/similar issue, and would love to contibute to crnk by fixing this. Do you have any recommendations of where/how to get started on that? |
Hey guys,
I just noticed that katharsis is dead and switched to crnk. Refactoring was really easy so far, thanks for that.
However, I experience problems when it comes to mapping exceptions. On the server side I throw an "ImportException" which extends RuntimeException. I wrote an ExceptionMapper that maps to a bad RequestException and sets the ErrorData (error code inclusive) on the ErrorResponse. The mapper is executed on the server, the response looks fine but on the client side it seems that exception mapper is not registered (or maybe I miss something here). Therefore, in my testcases, I receive a BadRequestException but with no ErrorData.code.
Do I need to register the exception mapper on the client or will it be auto-discovered? I also tried to register a new module that adds the exception mapper -> no result.
With katharsis I had a similar problem. It seemed that the cause was katharsis-project/katharsis-framework#448 but I am not sure if this still holds for crnk.
build.gradle
** SpringBoot Application class **
Exception thrown by a repository
Response from server.. This looks great
Expected behaviour: Test passes
Actual behaviour:
org.junit.ComparisonFailure:
Expected :"DUPLICATE_ID"
Actual :null
The text was updated successfully, but these errors were encountered: