Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 42 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ members = [
version = "0.1.0"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "dd99c5c1d7f2ade92451d21eb20fccca59237b84"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"

[patch.crates-io.ic-types]
version = "0.1.2"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "dd99c5c1d7f2ade92451d21eb20fccca59237b84"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"

[patch.crates-io.ic-utils]
version = "0.1.0"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "dd99c5c1d7f2ade92451d21eb20fccca59237b84"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"
4 changes: 2 additions & 2 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
"type": "git"
},
"ic-ref": {
"branch": "release-0.11",
"branch": "release-0.13",
"repo": "ssh://git@github.com/dfinity-lab/ic-ref",
"rev": "9edd0fdda006519118ed40515b84c74f69c59bc1",
"rev": "d08472d437c95534ee3d09e635a370522ea0fd37",
"type": "git"
},
"motoko": {
Expand Down
6 changes: 3 additions & 3 deletions src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ wasmparser = "0.45.0"
version = "0.1.0"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "dd99c5c1d7f2ade92451d21eb20fccca59237b84"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"

[dependencies.ic-types]
version = "0.1.2"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "dd99c5c1d7f2ade92451d21eb20fccca59237b84"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"

[dependencies.ic-utils]
version = "0.1.0"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "dd99c5c1d7f2ade92451d21eb20fccca59237b84"
rev = "6c02ef4bf25d82652ceb60c93b9df1a8863f0524"

[dev-dependencies]
env_logger = "0.6"
Expand Down
24 changes: 2 additions & 22 deletions src/dfx/src/lib/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,8 @@ impl Display for DfxError {
reject_code, reject_message
))?;
}
DfxError::AgentError(AgentError::HttpError {
status,
content_type,
content,
}) if is_plain_text_utf8(content_type) => {
f.write_fmt(format_args!(
"Replica error (HTTP status {}): {}",
status,
String::from_utf8(content.to_vec()).unwrap_or_else(|from_utf8_err| format!(
"(unable to decode content: {:#?})",
from_utf8_err
))
))?;
DfxError::AgentError(AgentError::HttpError(http_error_payload)) => {
f.write_fmt(format_args!("Replica error: {}", http_error_payload))?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.

}
DfxError::Unknown(err) => {
f.write_fmt(format_args!("Unknown error: {}", err))?;
Expand Down Expand Up @@ -341,12 +330,3 @@ impl From<delay::WaiterError> for DfxError {
DfxError::WaiterError(err)
}
}

fn is_plain_text_utf8(content_type: &Option<String>) -> bool {
// text/plain is also sometimes returned by the replica (or ic-ref),
// depending on where in the stack the error happens.
matches!(
content_type.as_ref().and_then(|s|s.parse::<mime::Mime>().ok()),
Some(mt) if mt == mime::TEXT_PLAIN || mt == mime::TEXT_PLAIN_UTF_8
)
}