-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathErr.InvalidColumnNames.pq
More file actions
47 lines (42 loc) · 1.69 KB
/
Err.InvalidColumnNames.pq
File metadata and controls
47 lines (42 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
let
// creates a new ErrorRecord fo you to throw
Err.InvalidColumnNames = (
source as table,
columnNames as list,
optional options as nullable record
) as record => [
// or table source could be name,
// assert = if sourceOrName is table then
// Columns.ThatExist( sourceOrName, columnNames )
// else
// true,
// assertAllowedKeys = {"Reason", "Detail", "Message.Parameters", "Message.Format" },
// tableName = if source is text then source else Expression.Identifier(source),
FmtList = TransformTo.TextList,
FmtNL = Format.JoinNewLine,
MissingColumns = List.RemoveItems( columnNames, Table.ColumnNames( source) ),
err = [
Reason = options[Reason]? ?? options[ExceptionName]? ??
"InvalidColumnsException",
Detail = options[Detail]? ??
"Exact column names did not match. Verify capitalization and whitespace",
Message.Parameters = {
source, // AsText?
FmtList( columnNames ),
FmtList( Table.ColumnNames(source) ),
FmtList( MissingColumns )
},
Message.Format = options[Message.Format]? ??
FmtNL({ "",
"RequiredParameterMissingValues ColumnNames: ",
"Table: #{0}",
"Wanted: ",
" #{1}",
"Found: ",
" #{2}",
"Missing: ",
" #{3}"
})
]
][err]
in Err.InvalidColumnNames