One of the complaints of users on our first Hack call was that the error
messages you got when channel joining failed were not great.
This aims to fix that specific case, and lay the groundwork for future
improvements.
It adds two new methods to anyhow::Error
* `.error_code()` which returns a value from zed.proto (or
ErrorCode::Internal if the error has no specific tag)
* `.error_tag("key")` which returns the value of the tag (or None).
To construct errors with these fields set, you can use a builder API
based on the ErrorCode type:
* `Err(ErrorCode::Forbidden.anyhow())`
* `Err(ErrorCode::Forbidden.message("cannot join channel").into())` - to
add any context you want in the logs
* `Err(ErrorCode::WrongReleaseChannel.tag("required", "stable").into())`
- to add structured metadata to help the client handle the error better.
Release Notes:
- Improved error messaging when channel joining fails.
63 lines
2.1 KiB
Rust
63 lines
2.1 KiB
Rust
use gpui::{actions, AppContext, ClipboardItem, PromptLevel};
|
|
use system_specs::SystemSpecs;
|
|
use workspace::Workspace;
|
|
|
|
pub mod deploy_feedback_button;
|
|
pub mod feedback_modal;
|
|
|
|
actions!(feedback, [GiveFeedback, SubmitFeedback]);
|
|
|
|
mod system_specs;
|
|
|
|
actions!(
|
|
zed,
|
|
[
|
|
CopySystemSpecsIntoClipboard,
|
|
FileBugReport,
|
|
RequestFeature,
|
|
OpenZedRepo
|
|
]
|
|
);
|
|
|
|
pub fn init(cx: &mut AppContext) {
|
|
// TODO: a way to combine these two into one?
|
|
cx.observe_new_views(feedback_modal::FeedbackModal::register)
|
|
.detach();
|
|
|
|
cx.observe_new_views(|workspace: &mut Workspace, _| {
|
|
workspace
|
|
.register_action(|_, _: &CopySystemSpecsIntoClipboard, cx| {
|
|
let specs = SystemSpecs::new(&cx).to_string();
|
|
|
|
let prompt = cx.prompt(
|
|
PromptLevel::Info,
|
|
"Copied into clipboard",
|
|
Some(&specs),
|
|
&["OK"],
|
|
);
|
|
cx.spawn(|_, _cx| async move {
|
|
prompt.await.ok();
|
|
})
|
|
.detach();
|
|
let item = ClipboardItem::new(specs.clone());
|
|
cx.write_to_clipboard(item);
|
|
})
|
|
.register_action(|_, _: &RequestFeature, cx| {
|
|
let url = "https://github.com/zed-industries/zed/issues/new?assignees=&labels=enhancement%2Ctriage&template=0_feature_request.yml";
|
|
cx.open_url(url);
|
|
})
|
|
.register_action(move |_, _: &FileBugReport, cx| {
|
|
let url = format!(
|
|
"https://github.com/zed-industries/zed/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
|
|
urlencoding::encode(&SystemSpecs::new(&cx).to_string())
|
|
);
|
|
cx.open_url(&url);
|
|
})
|
|
.register_action(move |_, _: &OpenZedRepo, cx| {
|
|
let url = "https://github.com/zed-industries/zed";
|
|
cx.open_url(&url);
|
|
});
|
|
})
|
|
.detach();
|
|
}
|