From edbd4ad94ffe69516beaa6407adb38ec52ff4648 Mon Sep 17 00:00:00 2001 From: jackfoxy Date: Wed, 30 Nov 2022 15:06:42 -0800 Subject: [PATCH] clean up crash sites --- urql/lib/parse.hoon | 74 +++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 47 deletions(-) diff --git a/urql/lib/parse.hoon b/urql/lib/parse.hoon index fa47f00..8620ff8 100644 --- a/urql/lib/parse.hoon +++ b/urql/lib/parse.hoon @@ -180,7 +180,7 @@ (qualified-object:ast %qualified-object ~ current-database -.a +.a) ?@ a :: name (qualified-object:ast %qualified-object ~ current-database 'dbo' a) - !! + ~|("cannot parse qualified-object {}" !!) ++ cook-qualified-object :: @p.database.namespace.object-name |= a=* ~+ @@ -196,7 +196,7 @@ (qualified-object:ast %qualified-object ~ current-database -.a +.a) ?@ a :: name (qualified-object:ast %qualified-object ~ current-database 'dbo' a) - !! + ~|("cannot parse qualified-object {}" !!) ++ qualified-namespace :: database.namespace |= [a=* current-database=@t] ~+ @@ -276,7 +276,7 @@ ?: =(literal-list ~) $(b +.b, literal-list (a-co:co ->.b)) $(b +.b, literal-list (weld (weld (a-co:co ->.b) ";") literal-list)) - !! + ~|("cannot parse literal-list {}" !!) ++ value-literal-list ~+ (cook cook-literal-list ;~(pose ;~(pfix whitespace (ifix [pal par] (more com get-value-literal))) (ifix [pal par] (more com get-value-literal)))) ++ parse-insert-value ;~ pose @@ -288,15 +288,11 @@ :: :: used for various commands :: -++ crash - |= msg=tape - ~& msg - !! ++ cook-column |= a=* ?: ?=([@ @] [a]) (column:ast %column -.a +.a) - !! + ~|("cannot parse column {}" !!) ++ cook-ordered-column |= a=* ?@ a @@ -305,8 +301,7 @@ ?: =(+.a %asc) (ordered-column:ast %ordered-column -.a %.y) (ordered-column:ast %ordered-column -.a %.n) - !! - + ~|("cannot parse ordered-column {}" !!) ++ cook-referential-integrity |= a=* ?: ?=([[@ @] @ @] [a]) :: cascade, cascade @@ -329,7 +324,7 @@ ~ ?: ?=([[@ @ [@ %~] @] @ @ [@ %~] @] a) :: no action, no action ~ - !! + ~|("cannot parse ordered-column {}" !!) ++ end-or-next-command ;~ plug (cold %end-command ;~(pose ;~(plug whitespace mic) whitespace mic)) (easy ~) @@ -441,7 +436,7 @@ (foreign-key:ast %foreign-key -<.a ->-.a ->+<-.a ->+<+.a ->+>.a +.a) ?: ?=([[@ [[@ @ @] %~] @ [@ %~]] *] [a]) :: foreign key table ... references fk-table ... on action on action (foreign-key:ast %foreign-key -<.a ->-.a ->+<-.a 'dbo' ->+.a +.a) - !! + ~|("cannot parse foreign-key {}" !!) ++ build-foreign-keys |= a=[table=qualified-object:ast f-keys=(list *)] ~+ @@ -523,7 +518,7 @@ (query-object:ast %query-object parsed ~) ?: ?=([[@ @ @ @ @] @] parsed) (query-object:ast %query-object -.parsed `+.parsed) - !! + ~|("cannot parse query-object {}" !!) ++ parse-cross-joined-object ~+ ;~(plug parse-cross-join-type parse-query-object) ::(cook cook-joined-object ;~(plug parse-cross-join-type parse-query-object)) ++ parse-joined-object ~+ ;~ plug @@ -572,7 +567,7 @@ (qualified-column:ast %qualified-column (qualified-object:ast %qualified-object ~ 'UNKNOWN' 'COLUMN' -.a) +.a ~) ?@ a :: column, column alias, or cte (qualified-column:ast %qualified-column (qualified-object:ast %qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' a) a ~) - !! + ~|("cannot parse qualified-column {}" !!) ++ parse-column ~+ ;~ pose ;~((glue dot) parse-ship sym sym sym sym) ;~(plug parse-ship ;~(pfix dot sym) dot dot sym ;~(pfix dot sym)) @@ -1025,7 +1020,7 @@ ?: ?=(value-literal:ast -.parsed) ?: =('else' +>-.parsed) (case:ast %case -.parsed (flop cases) +>+<.parsed) (case:ast %case -.parsed (flop cases) ~) - !! + ~|("cannot parse case {}" !!) ++ parse-case ;~ plug parse-datum (star parse-when-then) @@ -1226,14 +1221,12 @@ =/ raw-joined-objects +.a =/ joined-objects=(list joined-object:ast) ~ =/ is-cross-join=? %.n - ~| "a: {}" |- - ~| "->+>.raw-joined-objects: {<->+>.raw-joined-objects>}" ?: =(raw-joined-objects ~) ?: is-cross-join ?: =((lent joined-objects) 1) (from:ast query-object %from query-object (flop joined-objects)) - (crash "cross join must be only join in query") + ~|("cross join must be only join in query" !!) (from:ast query-object %from query-object (flop joined-objects)) ::~& "raw-joined-objects: {}" :: ->-.raw-joined-objects join type @@ -1291,7 +1284,7 @@ :: ?: ?&(=(-.a %bottom) ?=(@ud +<.a)) $(a +>.a, bottom `+<.a) :: ?: =(-.a %distinct) $(a +.a, distinct %.y) :: ?: =(-.a %all) $(a ~, columns ~[(selected-column:ast %all)]) - !! + ~|("cannot parse select {}" !!) ++ cook-simple-query |= a=(list *) ^- simple-query:ast @@ -1303,7 +1296,7 @@ =/ having=(unit having:ast) ~ =/ order-by=(unit order-by:ast) ~ |- - ?~ a !! + ?~ a ~|("cannot parse simple-query {}" !!) ?: =(i.a %query) ~& "%query" $(a t.a) ?: =(i.a %end-command) (simple-query:ast %simple-query from scalars predicate (need select) group-by having order-by) ::?: =(i.a %scalars) $(a t.a, scalars +.i.a) @@ -1315,7 +1308,7 @@ ?: =(-<.a %order-by) ~& "%order-by" $(a t.a, order-by ~) ?: =(-<-.a %query-object) ~& "%query-object" $(a t.a, from `(produce-from i.a)) :: ?: =(-<-.a %query-object) ~& "%query-object" $(a t.a, from ~) - (crash "fucked up something {}") + ~|("cannot parse simple-query {}" !!) :: :: parse urQL command :: @@ -1446,11 +1439,9 @@ =/ check-empty u.+3:q.+3:(whitespace [[1 1] script]) ?: =(0 (lent q.q:check-empty)) :: trailing whitespace after last end-command (;) (flop commands) - ~| "Error parsing command keyword: {}" =/ command-nail u.+3:q.+3:(parse-command [script-position script]) ?- `command`p.command-nail %alter-index - ~| "Cannot parse alter-index {}" =/ index-nail (parse-alter-index [[1 1] q.q.command-nail]) =/ parsed (wonk index-nail) =/ next-cursor @@ -1483,9 +1474,8 @@ commands [`command-ast`(alter-index:ast %alter-index -.parsed +<.parsed +>.parsed %rebuild) commands] == - !! + ~|("Cannot parse alter-index {}" !!) %alter-namespace - ~| "Cannot parse namespace {}" =/ namespace-nail (parse-alter-namespace [[1 1] q.q.command-nail]) =/ parsed (wonk namespace-nail) =/ next-cursor @@ -1497,7 +1487,6 @@ [`command-ast`(alter-namespace:ast %alter-namespace -<.parsed ->.parsed +<.parsed +>+>+<.parsed +>+>+>.parsed) commands] == %alter-table - ~| "Cannot parse table {}" =/ table-nail (parse-alter-table [[1 1] q.q.command-nail]) =/ parsed (wonk table-nail) =/ next-cursor @@ -1537,7 +1526,7 @@ commands [`command-ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +>.parsed) commands] == - !! + ~|("Cannot parse table {}" !!) %create-database ~| 'Create database must be only statement in script' ?> =((lent commands) 0) @@ -1547,7 +1536,6 @@ [`command-ast`(create-database:ast %create-database p.u.+3:q.+3:(parse-face [[1 1] q.q.command-nail])) commands] == %create-index - ~| "Cannot parse index {}" =/ index-nail (parse-create-index [[1 1] q.q.command-nail]) =/ parsed (wonk index-nail) =/ next-cursor @@ -1581,7 +1569,7 @@ commands [`command-ast`(create-index:ast %create-index ->.parsed +<.parsed %.n %.n +>.parsed) commands] == - !! + ~|("Cannot parse index {}" !!) ?: ?=([[@ @ @] [* *]] [parsed]) ?: =(->-.parsed %clustered) ::"create unique clustered index ..." %= $ @@ -1597,10 +1585,9 @@ commands [`command-ast`(create-index:ast %create-index ->+.parsed +<.parsed %.y %.n +>.parsed) commands] == - !! - !! + ~|("Cannot parse index {}" !!) + ~|("Cannot parse index {}" !!) %create-namespace - ~| "Cannot parse name to term in create-namespace {}" =/ create-namespace-nail (parse-create-namespace [[1 1] q.q.command-nail]) =/ parsed (wonk create-namespace-nail) =/ next-cursor @@ -1617,7 +1604,6 @@ commands [`command-ast`(create-namespace:ast %create-namespace -.parsed +.parsed) commands] == %create-table - ~| "Cannot parse table {}" =/ table-nail (parse-create-table [[1 1] q.q.command-nail]) =/ parsed (wonk table-nail) =/ next-cursor @@ -1638,7 +1624,6 @@ %create-view !! %drop-database - ~| "Cannot parse drop-database {}" =/ drop-database-nail (parse-drop-database [[1 1] q.q.command-nail]) =/ parsed (wonk drop-database-nail) =/ next-cursor @@ -1655,9 +1640,9 @@ script-position next-cursor commands [`command-ast`(drop-database:ast %drop-database +.parsed %.y) commands] == + ::~|("Cannot parse drop-database {}" !!) !! %drop-index - ~| "Cannot parse drop-index {}" =/ drop-index-nail (parse-drop-index [[1 1] q.q.command-nail]) =/ parsed (wonk drop-index-nail) =/ next-cursor @@ -1668,7 +1653,6 @@ commands [`command-ast`(drop-index:ast %drop-index -.parsed +.parsed) commands] == %drop-namespace - ~| "Cannot parse drop-namespace {}" =/ drop-namespace-nail (parse-drop-namespace [[1 1] q.q.command-nail]) =/ parsed (wonk drop-namespace-nail) =/ next-cursor @@ -1697,9 +1681,9 @@ script-position next-cursor commands [`command-ast`(drop-namespace:ast %drop-namespace +<.parsed +>.parsed %.y) commands] == + ::~|("Cannot parse drop-namespace {}" !!) !! %drop-table - ~| "Cannot parse drop-table {}" =/ drop-table-nail (drop-table-or-view [[1 1] q.q.command-nail]) =/ parsed (wonk drop-table-nail) =/ next-cursor @@ -1718,9 +1702,8 @@ commands [`command-ast`(drop-table:ast %drop-table parsed %.n) commands] == - !! + ~|("Cannot parse drop-table {}" !!) %drop-view - ~| "Cannot parse drop-view {}" =/ drop-view-nail (drop-table-or-view [[1 1] q.q.command-nail]) =/ parsed (wonk drop-view-nail) =/ next-cursor @@ -1739,9 +1722,8 @@ commands [`command-ast`(drop-view:ast %drop-view parsed %.n) commands] == - !! + ~|("Cannot parse drop-view {}" !!) %grant - ~| "Cannot parse grant {}" =/ grant-nail (parse-grant [[1 1] q.q.command-nail]) =/ parsed (wonk grant-nail) =/ next-cursor @@ -1774,9 +1756,8 @@ commands [`command-ast`(grant:ast %grant -.parsed +<.parsed +>.parsed) commands] == - !! + ~|("Cannot parse grant {}" !!) %insert - ~| "Cannot parse insert {}" =/ insert-nail (parse-insert [[1 1] q.q.command-nail]) =/ parsed (wonk insert-nail) =/ next-cursor @@ -1796,7 +1777,7 @@ commands [`command-ast`(insert:ast %insert -.parsed `+<-.parsed (insert-values:ast %data +>-.parsed)) commands] == - !! + ~|("Cannot parse insert {}" !!) %query ~| "Cannot parse query {}" ~| "q.q.command-nail: {}" @@ -1808,7 +1789,7 @@ ~| "remainder: {}" !! %revoke - ~| "Cannot parse revoke {}" + =/ revoke-nail (parse-revoke [[1 1] q.q.command-nail]) =/ parsed (wonk revoke-nail) =/ next-cursor @@ -1841,9 +1822,8 @@ commands [`command-ast`(revoke:ast %revoke -.parsed +<.parsed +>.parsed) commands] == - !! + ~|("Cannot parse revoke {}" !!) %truncate-table - ~| "Cannot parse truncate-table {}" =/ truncate-table-nail (parse-truncate-table [[1 1] q.q.command-nail]) =/ next-cursor (get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:truncate-table-nail])