| 1 |
# spec() gives useful errors |
| 2 |
|
| 3 |
Code |
| 4 |
spec(1) |
| 5 |
Condition |
| 6 |
Error: |
| 7 |
! `what` must be a single string, not the number 1. |
| 8 |
|
| 9 |
--- |
| 10 |
|
| 11 |
Code |
| 12 |
spec("foo") |
| 13 |
Condition |
| 14 |
Error: |
| 15 |
! `what` must have function call syntax. |
| 16 |
|
| 17 |
# Good: |
| 18 |
signal_lifecycle("foo()") |
| 19 |
|
| 20 |
# Bad: |
| 21 |
signal_lifecycle("foo") |
| 22 |
|
| 23 |
--- |
| 24 |
|
| 25 |
Code |
| 26 |
spec("foo()()") |
| 27 |
Condition |
| 28 |
Error: |
| 29 |
! `what` must be a function or method call. |
| 30 |
|
| 31 |
--- |
| 32 |
|
| 33 |
Code |
| 34 |
spec("foo(arg = , arg = )") |
| 35 |
Condition |
| 36 |
Error: |
| 37 |
! Function in `what` (foo) must have 1 argument, not 2. |
| 38 |
|
| 39 |
--- |
| 40 |
|
| 41 |
Code |
| 42 |
spec("foo(arg = arg)") |
| 43 |
Condition |
| 44 |
Error: |
| 45 |
! `what` must contain reason as a string on the RHS of `=`. |
| 46 |
|
| 47 |
# Good: |
| 48 |
signal_lifecycle("foo(arg = 'must be a string')") |
| 49 |
|
| 50 |
# Bad: |
| 51 |
signal_lifecycle("foo(arg = 42)") |
| 52 |
|
| 53 |
--- |
| 54 |
|
| 55 |
Code |
| 56 |
spec("foo()", env = e) |
| 57 |
Condition |
| 58 |
Error: |
| 59 |
! Can't detect the package of the deprecated function. |
| 60 |
Please mention the namespace: |
| 61 |
|
| 62 |
# Good: |
| 63 |
signal_lifecycle(what = "namespace::myfunction()") |
| 64 |
|
| 65 |
# Bad: |
| 66 |
signal_lifecycle(what = "myfunction()") |
| 67 |
|
| 68 |
# spec() works with methods |
| 69 |
|
| 70 |
Code |
| 71 |
spec("A$foo(bar = 1)") |
| 72 |
Condition |
| 73 |
Error: |
| 74 |
! `what` must contain reason as a string on the RHS of `=`. |
| 75 |
|
| 76 |
# Good: |
| 77 |
signal_lifecycle("A$foo(arg = 'must be a string')") |
| 78 |
|
| 79 |
# Bad: |
| 80 |
signal_lifecycle("A$foo(arg = 42)") |
| 81 |
|