Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix when compilation is failed to return null filemap
Browse files Browse the repository at this point in the history
  • Loading branch information
varex83 committed Nov 7, 2023
1 parent 1b005d9 commit a01e429
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions api/src/handlers/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,29 @@ pub async fn do_compile(remix_file_path: PathBuf) -> Result<Json<CompileResponse
}
}

let status = status_code_to_message(output.status.code());
let message = String::from_utf8(output.stderr)
.map_err(ApiError::UTF8Error)?
.replace(
&file_path
.to_str()
.ok_or(ApiError::FailedToParseString)?
.to_string(),
&remix_file_path,
)
.replace(&result_path_prefix, &remix_file_path);

if status != "Success" {
return Ok(Json(CompileResponse {
message,
status,
file_content: vec![],
}));
}

Ok(Json(CompileResponse {
message: String::from_utf8(output.stderr)
.map_err(ApiError::UTF8Error)?
.replace(
&file_path
.to_str()
.ok_or(ApiError::FailedToParseString)?
.to_string(),
&remix_file_path,
)
.replace(&result_path_prefix, &remix_file_path),
status: status_code_to_message(output.status.code()),
message,
status,
file_content: compiled_contracts,
}))
}

0 comments on commit a01e429

Please sign in to comment.