告诉 F# reraise returns 没有价值
Tell F# that reraise returns no value
如何帮助 F# 编译器将重新抛出的异常解释为没有 return 值?
例如,考虑包装一个操作来记录异常:
let doDivision() =
try
2 / 0
with ex ->
log ex
reraise
编译器针对 reraise
报告此错误:
This expression was expected to have type int
but here has type unit -> 'a
"reraise" 是一个函数。您需要将单位传递给它。
let doDivision() =
try
2 / 0
with ex ->
log ex
reraise ()
如何帮助 F# 编译器将重新抛出的异常解释为没有 return 值?
例如,考虑包装一个操作来记录异常:
let doDivision() =
try
2 / 0
with ex ->
log ex
reraise
编译器针对 reraise
报告此错误:
This expression was expected to have type
int
but here has typeunit -> 'a
"reraise" 是一个函数。您需要将单位传递给它。
let doDivision() =
try
2 / 0
with ex ->
log ex
reraise ()