MCPcopy Create free account
hub / github.com/devflowinc/trieve / error_response

Method error_response

pdf2md/server/src/errors.rs:46–84  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

44// impl ResponseError trait allows to convert our errors into http responses with appropriate data
45impl ResponseError for ServiceError {
46 fn error_response(&self) -> HttpResponse {
47 match self {
48 ServiceError::InternalServerError(ref message) => HttpResponse::InternalServerError()
49 .json(ErrorResponseBody {
50 message: message.to_string(),
51 }),
52 ServiceError::BadRequest(ref message) => {
53 HttpResponse::BadRequest().json(ErrorResponseBody {
54 message: message.to_string(),
55 })
56 }
57 ServiceError::DuplicateTrackingId(ref id) => {
58 HttpResponse::BadRequest().json(ErrorResponseBody {
59 message: format!("Stoped overwriting data, Duplicate Tracking Id {:?}", id),
60 })
61 }
62 ServiceError::Unauthorized => HttpResponse::Unauthorized().json(ErrorResponseBody {
63 message: "Unauthorized".to_string(),
64 }),
65 ServiceError::Forbidden => HttpResponse::Forbidden().json(ErrorResponseBody {
66 message: "Forbidden".to_string(),
67 }),
68 ServiceError::NotFound(ref message) => {
69 HttpResponse::NotFound().json(ErrorResponseBody {
70 message: format!("Not Found: {}", message),
71 })
72 }
73 ServiceError::JsonDeserializeError(ref message) => {
74 HttpResponse::BadRequest().json(ErrorResponseBody {
75 message: format!("Json Deserialization Error: {}", message),
76 })
77 }
78 ServiceError::PayloadTooLarge(ref message) => {
79 HttpResponse::PayloadTooLarge().json(ErrorResponseBody {
80 message: message.to_string(),
81 })
82 }
83 }
84 }
85}
86
87// we can return early in our handlers if UUID provided by the user is not valid

Callers

nothing calls this directly

Calls 2

NotFoundFunction · 0.85
to_stringMethod · 0.80

Tested by

no test coverage detected