Binary.ViewError

Binary

Creates a modified error record that prevents fallback to default behavior when raised by a Binary.View handler.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Binary.ViewError(errorRecord as record) as record

Parameters

NameTypeRequiredDescription
errorRecordrecordYesAn error record (with Reason, Message, and optionally Detail fields) to wrap as a non-fallback error.

Return Value

recordA modified error record that, when raised inside a Binary.View handler, prevents fallback to the default operation.

Remarks

Binary.ViewError creates a modified error record from the given errorRecord that, when raised by a handler defined on a Binary.View, will not trigger a fallback to the default operation behavior. This is the binary-stream equivalent of Table.ViewError.

By default, when a Binary.View handler raises an error, the engine falls back to applying the operation using the default behavior on the base binary. Wrapping the error with Binary.ViewError prevents this fallback, causing the error to be surfaced directly to the caller.

This is useful in custom connectors when a handler detects a condition that should be reported as a hard failure rather than silently degrading to the default behavior.

Examples

Example 1: Raise a non-fallback error from a view handler

let
    View = Binary.View(
        Text.ToBinary("test data"),
        [
            GetLength = () =>
                error Binary.ViewError(
                    [Reason = "Expression.Error", Message = "Length not supported for this source"]
                )
        ]
    )
in
    try Binary.Length(View)
Applied Steps

Attempts to get the length of the view. Because the handler raises a Binary.ViewError, the engine does not fall back to counting bytes — instead it surfaces the error directly.

Value
1[HasError = true, Error = [Reason = "Expression.Error", Message = "Length not supported for this source"]]

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks