[−][src]Struct rocket_json::error::Error
A specialized Status
struct that responds json errors.
This struct implements a Responder
that will return json.
Examples
use rocket_contrib::json::JsonValue; use rocket_json::{Error, Result}; fn example(error: bool) -> Result<JsonValue> { if error { // Rocket will return status code 503: // { "reason": "Service Unavailable", "status": 503 } return Err(Error::ServiceUnavailable); } // Rocket will return status code 200: // { "example": 42 } Ok(json!({ "example": 42 })) }
Fields
code: u16
reason: &'static str
Methods
impl Error
[src]
pub fn new(code: u16, reason: &'static str) -> Self
[src]
pub fn extend(self, data: JsonValue) -> Self
[src]
pub const MultipleChoices: Error
[src]
Error
with code
300
and reason
Multiple Choices
.
pub const MovedPermanently: Error
[src]
Error
with code
301
and reason
Moved Permanently
.
pub const Found: Error
[src]
Error
with code
302
and reason
Found
.
pub const SeeOther: Error
[src]
Error
with code
303
and reason
See Other
.
pub const NotModified: Error
[src]
Error
with code
304
and reason
Not Modified
.
pub const UseProxy: Error
[src]
Error
with code
305
and reason
Use Proxy
.
pub const TemporaryRedirect: Error
[src]
Error
with code
307
and reason
Temporary Redirect
.
pub const PermanentRedirect: Error
[src]
Error
with code
308
and reason
Permanent Redirect
.
pub const BadRequest: Error
[src]
Error
with code
400
and reason
Bad Request
.
pub const Unauthorized: Error
[src]
Error
with code
401
and reason
Unauthorized
.
pub const PaymentRequired: Error
[src]
Error
with code
402
and reason
Payment Required
.
pub const Forbidden: Error
[src]
Error
with code
403
and reason
Forbidden
.
pub const NotFound: Error
[src]
Error
with code
404
and reason
Not Found
.
pub const MethodNotAllowed: Error
[src]
Error
with code
405
and reason
Method Not Allowed
.
pub const NotAcceptable: Error
[src]
Error
with code
406
and reason
Not Acceptable
.
pub const ProxyAuthenticationRequired: Error
[src]
Error
with code
407
and reason
Proxy Authentication Required
.
pub const RequestTimeout: Error
[src]
Error
with code
408
and reason
Request Timeout
.
pub const Conflict: Error
[src]
Error
with code
409
and reason
Conflict
.
pub const Gone: Error
[src]
Error
with code
410
and reason
Gone
.
pub const LengthRequired: Error
[src]
Error
with code
411
and reason
Length Required
.
pub const PreconditionFailed: Error
[src]
Error
with code
412
and reason
Precondition Failed
.
pub const PayloadTooLarge: Error
[src]
Error
with code
413
and reason
Payload Too Large
.
pub const UriTooLong: Error
[src]
Error
with code
414
and reason
URI Too Long
.
pub const UnsupportedMediaType: Error
[src]
Error
with code
415
and reason
Unsupported Media Type
.
pub const RangeNotSatisfiable: Error
[src]
Error
with code
416
and reason
Range Not Satisfiable
.
pub const ExpectationFailed: Error
[src]
Error
with code
417
and reason
Expectation Failed
.
pub const ImATeapot: Error
[src]
Error
with code
418
and reason
I'm a teapot
.
pub const MisdirectedRequest: Error
[src]
Error
with code
421
and reason
Misdirected Request
.
pub const UnprocessableEntity: Error
[src]
Error
with code
422
and reason
Unprocessable Entity
.
pub const Locked: Error
[src]
Error
with code
423
and reason
Locked
.
pub const FailedDependency: Error
[src]
Error
with code
424
and reason
Failed Dependency
.
pub const UpgradeRequired: Error
[src]
Error
with code
426
and reason
Upgrade Required
.
pub const PreconditionRequired: Error
[src]
Error
with code
428
and reason
Precondition Required
.
pub const TooManyRequests: Error
[src]
Error
with code
429
and reason
Too Many Requests
.
pub const RequestHeaderFieldsTooLarge: Error
[src]
Error
with code
431
and reason
Request Header Fields Too Large
.
pub const UnavailableForLegalReasons: Error
[src]
Error
with code
451
and reason
Unavailable For Legal Reasons
.
pub const InternalServerError: Error
[src]
Error
with code
500
and reason
Internal Server Error
.
pub const NotImplemented: Error
[src]
Error
with code
501
and reason
Not Implemented
.
pub const BadGateway: Error
[src]
Error
with code
502
and reason
Bad Gateway
.
pub const ServiceUnavailable: Error
[src]
Error
with code
503
and reason
Service Unavailable
.
pub const GatewayTimeout: Error
[src]
Error
with code
504
and reason
Gateway Timeout
.
pub const HttpVersionNotSupported: Error
[src]
Error
with code
505
and reason
HTTP Version Not Supported
.
pub const VariantAlsoNegotiates: Error
[src]
Error
with code
506
and reason
Variant Also Negotiates
.
pub const InsufficientStorage: Error
[src]
Error
with code
507
and reason
Insufficient Storage
.
pub const LoopDetected: Error
[src]
Error
with code
508
and reason
Loop Detected
.
pub const NotExtended: Error
[src]
Error
with code
510
and reason
Not Extended
.
pub const NetworkAuthenticationRequired: Error
[src]
Error
with code
511
and reason
Network Authentication Required
.
Trait Implementations
impl Into<Status> for Error
[src]
impl PartialEq<Error> for Error
[src]
impl Clone for Error
[src]
fn clone(&self) -> Error
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<Status> for Error
[src]
impl Debug for Error
[src]
impl<'r> Responder<'r> for Error
[src]
fn respond_to(self, req: &Request) -> Result<Response<'r>, Status>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,