E0026#
Warning name: unused_catch_all
Hint
The syntax of catch! is deprecated.
The patterns are complete so the usage of catch! is useless. In MoonBit, when
there is only one error type that will be raised in a try block, compiler will
know that the error type is the only one that will be caught. So, there is no
need to use catch! in this case.
Erroneous example#
///|
suberror E
///|
fn f() -> Unit raise E {
raise E
}
///|
fn g() -> Unit raise {
f() catch! {
E => raise E
}
}
///|
fn main {
g() catch {
_ => println("Error")
}
}
Suggestion#
Remove the ! in the catch!:
///|
suberror E
///|
fn f() -> Unit raise E {
raise E
}
///|
fn g() -> Unit raise {
f() catch {
E => raise E
}
}
///|
fn main {
g() catch {
_ => println("Error")
}
}