File tree 2 files changed +14
-6
lines changed
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,22 @@ inline constexpr auto to_anyhow = [](std::string e) {
72
72
namespace toml {
73
73
74
74
template <typename T, typename ... U>
75
- inline auto
76
- try_find (const toml::value& v, const U&... u) noexcept
77
- -> Result<decltype(toml::find<T>(v, u...))> {
75
+ inline Result<T>
76
+ try_find (const toml::value& v, const U&... u) noexcept {
77
+ using namespace std ::string_view_literals; // NOLINT
78
+
78
79
try {
79
80
return Ok (toml::find<T>(v, u...));
80
81
} catch (const std::exception & e) {
81
- return Err (anyhow::anyhow (std::string (e.what ())));
82
+ std::string what = e.what ();
83
+ // TODO: make the same fix on upstream
84
+ if (what.starts_with (" [error] " )) {
85
+ what = what.substr (" [error] " sv.size ());
86
+ }
87
+ if (what.back () == ' \n ' ) {
88
+ what.pop_back (); // remove the last '\n' since logger::error adds one.
89
+ }
90
+ return Err (anyhow::anyhow (what));
82
91
}
83
92
}
84
93
Original file line number Diff line number Diff line change @@ -88,12 +88,11 @@ test_expect_success 'cabin fmt without name in manifest' '
88
88
echo "[package]" >cabin.toml &&
89
89
test_must_fail "$CABIN_BIN" fmt 2>actual &&
90
90
cat >expected <<-EOF &&
91
- Error: [error] toml::value::at: key "name" not found
91
+ Error: toml::value::at: key "name" not found
92
92
--> $(realpath $OUT)/pkg/cabin.toml
93
93
|
94
94
1 | [package]
95
95
| ^^^^^^^^^-- in this table
96
-
97
96
EOF
98
97
test_cmp expected actual
99
98
)
You can’t perform that action at this time.
0 commit comments