Raising errors
In Power Query’s M language, you can define custom errors. This is helpful when you want to provide more specific and meaningful error messages, be able to handle exceptional cases, enforce custom data validation rules, or improve the overall user experience for example.
The error expression
To raise an error, simply call the error-raising expression error
and use a text value to provide the desired error message you want to display. For example, this expression will raise the following error:
error "Invalid data, you did not provide a table."
Errors provide an error record; therefore, you can also specify a record to include more information about the error. This error record should contain fields such as Reason
, Message
, and Detail
. Here’s an example of how to raise an error with a custom error record:
error [
Reason = "Invalid data, you did not provide a table.",
Message = "The data provided is not...