Errors in Power Query generally halt query evaluation and display a message to the user.
Throwing an error with the
Throwing an error in Power Query is as simple as invoking the
let Source = "foo", Output = error "error message" in Output
Error.Record function can be used for more control.
let Source = "foo", Output = error Error.Record("error reason", "error message", "error detail") in Output
Catching an error with
try expression converts values and errors into a record value that indicates whether the
try expression handled an error or not, as well as the proper value of the error record.
If no error is found, the following record is returned from the
If an error is found, the following record is returned from the
The Error record contains Reason, Message, and Detail fields.
Depending on the error, the Detail field may contain additional information.
otherwise clause can be used with a
try expression to perform some action if an error occurs:
try "foo"+1 otherwise "There was an error"
is a more compact form of:
result = try "foo"+1, if result[HasError] then "There was an error" else result[Value]