Skip to content

Commit

Permalink
Merge pull request #132 from ngrok/josh/error-url
Browse files Browse the repository at this point in the history
ngrok: include url in error response Display implementation
  • Loading branch information
jrobsonchase authored Jan 3, 2024
2 parents bb3fa91 + 9b1737c commit 7a3eac6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ngrok/src/internals/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ impl<'a> From<&'a str> for ErrResp {

impl error::Error for ErrResp {}

const ERR_URL: &str = "https://ngrok.com/docs/errors";

impl fmt::Display for ErrResp {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.msg.fmt(f)?;
if let Some(code) = &self.error_code {
write!(f, "\n\nERR_NGROK_{code}")?;
if let Some(code) = self.error_code.as_ref().map(|s| s.to_lowercase()) {
write!(f, "\n\n{ERR_URL}/{code}")?;
}
Ok(())
}
Expand Down

0 comments on commit 7a3eac6

Please sign in to comment.