Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
94f647b2
There was an error fetching the commit references. Please try again later.
Unverified
Commit
94f647b2
authored
2 years ago
by
hybo
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
chore: evaluate error context lazily (#447)
parent
630249d2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src-tauri/src/config/profiles.rs
+4
-4
4 additions, 4 deletions
src-tauri/src/config/profiles.rs
src-tauri/src/utils/help.rs
+10
-7
10 additions, 7 deletions
src-tauri/src/utils/help.rs
with
14 additions
and
11 deletions
src-tauri/src/config/profiles.rs
+
4
−
4
View file @
94f647b2
...
...
@@ -138,9 +138,9 @@ impl IProfiles {
let
path
=
dirs
::
app_profiles_dir
()
?
.join
(
&
file
);
fs
::
File
::
create
(
path
)
.context
(
format!
(
"failed to create file
\"
{}
\"
"
,
file
))
?
.
with_
context
(
||
format!
(
"failed to create file
\"
{}
\"
"
,
file
))
?
.write
(
file_data
.as_bytes
())
.context
(
format!
(
"failed to write to file
\"
{}
\"
"
,
file
))
?
;
.
with_
context
(
||
format!
(
"failed to write to file
\"
{}
\"
"
,
file
))
?
;
}
if
self
.items
.is_none
()
{
...
...
@@ -207,9 +207,9 @@ impl IProfiles {
let
path
=
dirs
::
app_profiles_dir
()
?
.join
(
&
file
);
fs
::
File
::
create
(
path
)
.context
(
format!
(
"failed to create file
\"
{}
\"
"
,
file
))
?
.
with_
context
(
||
format!
(
"failed to create file
\"
{}
\"
"
,
file
))
?
.write
(
file_data
.as_bytes
())
.context
(
format!
(
"failed to write to file
\"
{}
\"
"
,
file
))
?
;
.
with_
context
(
||
format!
(
"failed to write to file
\"
{}
\"
"
,
file
))
?
;
}
break
;
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/utils/help.rs
+
10
−
7
View file @
94f647b2
...
...
@@ -11,19 +11,21 @@ pub fn read_yaml<T: DeserializeOwned>(path: &PathBuf) -> Result<T> {
}
let
yaml_str
=
fs
::
read_to_string
(
&
path
)
.context
(
format!
(
"failed to read the file
\"
{}
\"
"
,
path
.display
()))
?
;
.
with_
context
(
||
format!
(
"failed to read the file
\"
{}
\"
"
,
path
.display
()))
?
;
serde_yaml
::
from_str
::
<
T
>
(
&
yaml_str
)
.context
(
format!
(
"failed to read the file with yaml format
\"
{}
\"
"
,
path
.display
()
))
serde_yaml
::
from_str
::
<
T
>
(
&
yaml_str
)
.with_context
(||
{
format!
(
"failed to read the file with yaml format
\"
{}
\"
"
,
path
.display
()
)
})
}
/// read mapping from yaml fix #165
pub
fn
read_merge_mapping
(
path
:
&
PathBuf
)
->
Result
<
Mapping
>
{
let
mut
val
:
Value
=
read_yaml
(
path
)
?
;
val
.apply_merge
()
.context
(
format!
(
"failed to apply merge
\"
{}
\"
"
,
path
.display
()))
?
;
.
with_
context
(
||
format!
(
"failed to apply merge
\"
{}
\"
"
,
path
.display
()))
?
;
Ok
(
val
.as_mapping
()
...
...
@@ -45,7 +47,8 @@ pub fn save_yaml<T: Serialize>(path: &PathBuf, data: &T, prefix: Option<&str>) -
};
let
path_str
=
path
.as_os_str
()
.to_string_lossy
()
.to_string
();
fs
::
write
(
path
,
yaml_str
.as_bytes
())
.context
(
format!
(
"failed to save file
\"
{path_str}
\"
"
))
fs
::
write
(
path
,
yaml_str
.as_bytes
())
.with_context
(||
format!
(
"failed to save file
\"
{path_str}
\"
"
))
}
const
ALPHABET
:
[
char
;
62
]
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment