seed icon indicating copy to clipboard operation
seed copied to clipboard

[Enhancement] Improve debug output of `fetch::Response`

Open Ben-PH opened this issue 5 years ago • 0 comments

#513 Relevant discussion

The referred to PR was created in response to fetch::Response breaking my workflow when a Message had it in an assosciated type. For example:

#[derive(Debug)]
enum Message {
    SentMessage(fetch::Response),
}

fn update(msg: Message, _: &mut Model, _: &mut impl Orders<Message>) {
    match msg {
        _ => log!("Message handle not implemented", msg),
    }
}

with the error:

error[E0277]: `seed::browser::fetch::response::Response` doesn't implement `std::fmt::Debug`
  --> client/src/lib.rs:90:15
   |
90 |     LoginSent(fetch::Response),
   |               ^^^^^^^^^^^^^^^ `seed::browser::fetch::response::Response` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
   |

As noted in the linked discussion, the debug output of Response can get messy. Some possible solutions that come to mind:

  • Detect if one of the fields values is going to be too long, and replace that field with something like `"{:?} output excessive. Refer to Developer console for details"
  • Put the response into the console as a colapsable object similar to the image below (firefox example)

console console_expanded

Ben-PH avatar Aug 10 '20 02:08 Ben-PH