caddy/caddyconfig/caddyfile
Francis Lavoie 51f125bd44
caddyfile: Better error message for missing site block braces (#4301)
Some new users mistakenly try to define two sites without braces around each. Doing this can yield a confusing error message saying that their site address is an "unknown directive".

We can do better by keeping track of whether the current site block was parsed with or without a brace, then changing the error message later based on that.

For example, now this invalid config:

```
foo.example.com
respond "foo"

bar.example.com
respond "bar"
```

Will yield this error message:

```
$ caddy adapt
2021/08/22 19:21:31.028 INFO    using adjacent Caddyfile
adapt: Caddyfile:4: unrecognized directive: bar.example.com
Did you mean to define a second site? If so, you must use curly braces around each site to separate their configurations.
```
2021-08-23 11:53:27 -06:00
..
testdata caddyfile: reject cyclic imports (#4022) 2021-04-09 12:06:25 -06:00
adapter.go caddyfile: Normalize line endings before comparing fmt result (#4103) 2021-04-02 11:55:34 -06:00
dispenser_test.go caddyfile: keep error chain info in Dispenser.Errf (#4233) 2021-07-19 08:35:14 -06:00
dispenser.go caddyfile: keep error chain info in Dispenser.Errf (#4233) 2021-07-19 08:35:14 -06:00
formatter_fuzz.go fuzz: fix the FuzzFormat comparison (#4117) 2021-04-15 23:03:54 +00:00
formatter_test.go caddyfile: Fix caddy fmt nesting not decrementing (#4157) 2021-05-10 12:01:27 -06:00
formatter.go caddyfile: Fix caddy fmt nesting not decrementing (#4157) 2021-05-10 12:01:27 -06:00
importgraph.go caddyfile: reject cyclic imports (#4022) 2021-04-09 12:06:25 -06:00
lexer_fuzz.go ci: fuzz: add 4 more fuzzing targets (#4105) 2021-04-08 11:45:19 -06:00
lexer_test.go caddyfile: Export Tokenize function for lexing (#3549) 2020-07-20 13:55:51 -06:00
lexer.go caddyfile: reject cyclic imports (#4022) 2021-04-09 12:06:25 -06:00
parse_test.go caddyfile: Add parse error on site address with trailing { (#4163) 2021-05-12 16:18:44 -06:00
parse.go caddyfile: Better error message for missing site block braces (#4301) 2021-08-23 11:53:27 -06:00