Some common error codes for GET requests include:
-
301 Moved Permanently
- If the resource has been moved -
400 Bad Request
- If the client request is unaccaptable, i.e. if the client sends none-sense parameters in the request -
401 Unauthorized
- If the client did not provide any valid credentials -
403 Forbidden
- If the client is authorized but not allowed to perform the request (you can also return a 404 in this case to conceal that this resource exists at all) -
404 Not Found
- If the requested resource could not be found
Create a POJO to represent these error messages and then return it using a Jersey Response
object.
For example the error object could look like this:
public class ApiError {
private String code;
private String message;
private String developerMessage;
// Getters and Setters here
}
To return it you can do the following (i.e. in your catch block or your custom ExceptionMapper):
ApiError error = new ApiError("409-1", message, developerMessage);
return Response.status(Response.Status.CONFLICT).entity(error).build();
This way you can provide nicely formatted JSON/XML error messages containing custom error codes and further information for the developer. The error entities will get serialized according to your @Produces
annotation.
References:
相关推荐
### Meaningful Use Stage1提纲解析 #### 一、引言 Meaningful Use Stage1是美国政府在2011年推出的电子健康记录(EHR)激励计划的一部分,旨在鼓励医疗保健提供者采用和有效利用EHR系统,以提高医疗质量和效率,...
【BL模型】,全称为Black-Litterman模型,是投资组合优化领域中一个重要的理论工具。该模型由 Fischer Black 和 Ibbotson Associates 的 Robert Litterman 在1990年提出,旨在解决传统均值-方差优化(Mean-Variance ...
标题中的“Gives some meaningful error codes instead of the traditional”意味着这个资源或软件更新提供了一种改进的方法来处理错误,它不再使用旧式的、难以理解的自动化错误代码,而是提供了具有实际含义的错误...
本文将探讨在《信息安全_数据安全_Mechanisms for meaningful consen》这一主题下,如何保障隐私并实现有效的数据保护,特别是针对工业网络、移动设备以及隐私合规的挑战。 首先,隐私的定义是模糊的,它涵盖了个人...
A meaningful modification for the Tang-Toennies potential model: Application to He-He potential,盛晓伟,P.Li,the repulsive wall of the Tang-Toennies model is, unfortunately, generally too stiff....
Is the diagnosis of attention deficit/hyperactivity disorders meaningful? Psychology in (he Schools Voliinie 31, July 1994 ...because of unsatisfactory response to medical or edu
Organization of meaningful verbal material READING TESTS VERSUS INTELLIGENCE TESTS 365 REFERENCES GARRETT, HENRY E. Statistics in psychology and education. New York: Longmans, Green, 1961. ...
Visual Cryptography Scheme with Meaningful Shares Based on QR Codes
FM: Clinically meaningful rorschach index with minority children? Psjrhology in rht SchooLr 1981. / R . 429-433 FM: CLINICALLY MEANINGFUL RORSCHACH INDEX WITH MINORITY CHILDREN?' RALPH SCOTT ...
Meaningful Image Encryption Based on Reversible Data Hiding in Compressive Sensing Domain
Significant vs meaningful differences in the effects of tangible reinforcement on intelligence test achievement and reliability of tmr subjects SIGNIFICANT VS MEANINGFUL DIFFERENCES I N THE EFFECTS...
> mix deps.getnewb |> iex -S mix "use it Padawan"newb |> AST quote do - discover code patternsnewb |> require Loggernewb |> Logger.debug("debug message: Make it meaningful")newb |> alias :dbg, as: Dbg...
在这样的背景下,本文介绍了一种新颖的图像秘密共享技术,用于构建通用访问结构(General Access Structure, GAS),并且其具备有意义的图像(Meaningful Share),可以有效减少加密的怀疑并增强安全性。文章还提出...
本文档标题为《HardWareFirmwareDesign.pdf》,该文件是由HP公司的高级硬件工程师编写的关于硬件设计与固件设计方面的专业资料。从提供的部分内容来看,该文档强调了在硬件工程领域知识和最佳实践是不断变化的,随着...
的奋斗奋斗奋斗奋斗双方的首发第三方
VOSviewer是一款强大的科学可视化工具,特别适用于科研领域的文献分析和知识图谱构建。这款软件的最新版本为1.6.8,它以其易用性和高效性在科研人员中受到广泛赞誉。通过VOSviewer,用户可以有效地筛选、整理和理解...
But all of that data is just raw information -- to make that information meaningful, it has to be organized, filtered, and analyzed. Anyone can apply data analysis tools and get results, but without ...