Thep Excel

Table.ViewError – สร้าง View Error

สร้าง Error สำหรับ Table.View Handlers

=Table.ViewError(error as record) as any

By ThepExcel AI Agent
6 December 2025

Function Metrics


Popularity
2/10

Difficulty
7/10

Usefulness
3/10

Syntax & Arguments

=Table.ViewError(error as record) as any

Argument Type Required Default Description
error record Yes Record ที่ระบุรายละเอียดของ Error (เช่น Reason, Message)

How it works

Custom Connector Error Handling

Custom Connector Error Handling

Examples

สร้าง Error แบบง่าย
Table.ViewError([Reason = "CustomError", Message = "Something went wrong"])
สร้าง Error record เพื่อส่งกลับไปยัง Engine
Power Query Formula:

=Table.ViewError([Reason = "CustomError", Message = "Something went wrong"])

Result:

Error Record

ใช้ใน OnInvoke Handler
let View = Table.View(null, [ GetRows = () => ..., OnInvoke = (function, args) => if function = "RestrictedFunction" then Table.ViewError([Reason = "AccessDenie…
ตัวอย่างการใช้ Table.ViewError เพื่อปฏิเสธการเรียกใช้ฟังก์ชันบางอย่างใน Custom Connector
Power Query Formula:

let
    View = Table.View(null, [
        GetRows = () => ...,
        OnInvoke = (function, args) => 
            if function = "RestrictedFunction" then
                Table.ViewError([Reason = "AccessDenied", Message = "Function not allowed"])
            else
                ...
    ])
in
    View

Result:

Table View or Error

Error พร้อม Detail
Table.ViewError([ Reason = "Expression.Error", Message = "Column not found", Detail = "Column ID does not exist" ])
สร้าง Error ที่ระบุรายละเอียดเพิ่มเติมเพื่อช่วยในการ Debug
Power Query Formula:

=Table.ViewError([
    Reason = "Expression.Error",
    Message = "Column not found",
    Detail = "Column ID does not exist"
])

Result:

Error with Detail

Resources & Related

Additional Notes

ฟังก์ชัน Table.ViewError ใช้สำหรับโยน (Raise) Error ในบริบทของการทำงานของ Table.View โดยเฉพาะ เพื่อแจ้งให้ M Engine ทราบว่าเกิดข้อผิดพลาดที่ระดับ View Handlers

Leave a Reply

Your email address will not be published. Required fields are marked *