@Immutable public class ErrorObject extends Object
Example error object as HTTP response:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
{
"error" : "invalid_request"
}
| Constructor and Description |
|---|
ErrorObject(String code)
Creates a new error with the specified code.
|
ErrorObject(String code,
String description)
Creates a new error with the specified code and description.
|
ErrorObject(String code,
String description,
int httpStatusCode)
Creates a new error with the specified code, description and HTTP
status code.
|
ErrorObject(String code,
String description,
int httpStatusCode,
URI uri)
Creates a new error with the specified code, description, HTTP
status code and page URI.
|
| Modifier and Type | Method and Description |
|---|---|
ErrorObject |
appendDescription(String text)
Appends the specified text to the error description.
|
boolean |
equals(Object object) |
String |
getCode()
Gets the error code.
|
String |
getDescription()
Gets the error description.
|
int |
getHTTPStatusCode()
Gets the HTTP status code.
|
URI |
getURI()
Gets the error page URI.
|
int |
hashCode() |
static ErrorObject |
parse(HTTPResponse httpResponse)
Parses an error object from the specified HTTP response.
|
static ErrorObject |
parse(net.minidev.json.JSONObject jsonObject)
Parses an error object from the specified JSON object.
|
ErrorObject |
setDescription(String description)
Sets the error description.
|
ErrorObject |
setHTTPStatusCode(int httpStatusCode)
Sets the HTTP status code.
|
ErrorObject |
setURI(URI uri)
Sets the error page URI.
|
net.minidev.json.JSONObject |
toJSONObject()
Returns a JSON object representation of this error object.
|
String |
toString() |
public ErrorObject(String code)
code - The error code, null if not specified.public ErrorObject(String code, String description)
code - The error code, null if not specified.description - The error description, null if not
specified.public ErrorObject(String code, String description, int httpStatusCode)
code - The error code, null if not specified.description - The error description, null if not
specified.httpStatusCode - The HTTP status code, zero if not specified.public ErrorObject(String code, String description, int httpStatusCode, URI uri)
code - The error code, null if not specified.description - The error description, null if not
specified.httpStatusCode - The HTTP status code, zero if not specified.uri - The error page URI, null if not
specified.public String getDescription()
null if not specified.public ErrorObject setDescription(String description)
description - The error description, null if not
specified.public ErrorObject appendDescription(String text)
text - The text to append to the error description,
null if not specified.public int getHTTPStatusCode()
public ErrorObject setHTTPStatusCode(int httpStatusCode)
httpStatusCode - The HTTP status code, zero if not specified.public URI getURI()
null if not specified.public ErrorObject setURI(URI uri)
uri - The error page URI, null if not specified.public net.minidev.json.JSONObject toJSONObject()
Example:
{
"error" : "invalid_grant",
"error_description" : "Invalid resource owner credentials"
}
public static ErrorObject parse(net.minidev.json.JSONObject jsonObject)
jsonObject - The JSON object to parse. Must not be
null.public static ErrorObject parse(HTTPResponse httpResponse)
httpResponse - The HTTP response to parse. Must not be
null.Copyright © 2016 Connect2id Ltd.. All Rights Reserved.