Skip to content

Commit 9efb23c

Browse files
more context
1 parent 0d2d04f commit 9efb23c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ editor_options:
44
wrap: 72
55
---
66

7+
# precommit v0.3.1.9000
8+
9+
- `parsable-R` hook now gives more context on where and how parsing
10+
fails (#423).
11+
712
# precommit v0.3.1
813

914
**User visible changes**

inst/hooks/exported/parsable-R.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ out <- lapply(files, function(path) {
1111

1212
tryCatch(
1313
parse(path_),
14-
error = function(x) stop("File ", path, " is not parsable", call. = FALSE)
14+
error = function(error) {
15+
cat(c("File ", path, " is not parsable. Full context:\n"))
16+
stop(conditionMessage(error), call. = FALSE)
17+
}
1518
)
1619
})

tests/testthat/test-hooks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ run_test("parsable-R",
169169
)
170170

171171
# failure
172-
run_test("parsable-R", suffix = "-fail.R", std_err = "not parsable")
172+
run_test("parsable-R", suffix = "-fail.R", std_out = "Full context", std_err = "1 1")
173173

174174
run_test(
175175
"parsable-R",

0 commit comments

Comments
 (0)