fix(router): Fix HTTP status codes
This commit is contained in:
parent
6c781025ae
commit
91f5f86280
|
@ -220,7 +220,7 @@ impl From<InferError> for (StatusCode, Json<ErrorResponse>) {
|
||||||
fn from(err: InferError) -> Self {
|
fn from(err: InferError) -> Self {
|
||||||
match err {
|
match err {
|
||||||
InferError::GenerationError(_) => (
|
InferError::GenerationError(_) => (
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::FAILED_DEPENDENCY,
|
||||||
Json(ErrorResponse {
|
Json(ErrorResponse {
|
||||||
error: err.to_string(),
|
error: err.to_string(),
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn validation_worker(
|
||||||
) {
|
) {
|
||||||
// Loop over requests
|
// Loop over requests
|
||||||
while let Some((request, response_tx)) = receiver.blocking_recv() {
|
while let Some((request, response_tx)) = receiver.blocking_recv() {
|
||||||
if request.parameters.temperature < 0.0 {
|
if request.parameters.temperature <= 0.0 {
|
||||||
response_tx
|
response_tx
|
||||||
.send(Err(ValidationError::Temperature))
|
.send(Err(ValidationError::Temperature))
|
||||||
.unwrap_or(());
|
.unwrap_or(());
|
||||||
|
@ -162,7 +162,7 @@ pub enum ValidationError {
|
||||||
impl From<ValidationError> for (StatusCode, Json<ErrorResponse>) {
|
impl From<ValidationError> for (StatusCode, Json<ErrorResponse>) {
|
||||||
fn from(err: ValidationError) -> Self {
|
fn from(err: ValidationError) -> Self {
|
||||||
(
|
(
|
||||||
StatusCode::BAD_REQUEST,
|
StatusCode::UNPROCESSABLE_ENTITY,
|
||||||
Json(ErrorResponse {
|
Json(ErrorResponse {
|
||||||
error: err.to_string(),
|
error: err.to_string(),
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue