Skip to content

Commit 36e3f4f

Browse files
committed
adjusted exception message
1 parent cb88b81 commit 36e3f4f

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/Neon/TokenStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ public function error(?string $message = null, ?int $pos = null): void
9292
$message ??= 'Unexpected ' . ($token === null
9393
? 'end'
9494
: "'" . str_replace("\n", '<new line>', substr($this->tokens[$pos]->value, 0, 40)) . "'");
95-
throw new Exception("$message on line $line, column $col.");
95+
throw new Exception("$message on line $line at column $col");
9696
}
9797
}

tests/Neon/Decoder.errors.phpt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,63 +16,63 @@ require __DIR__ . '/../bootstrap.php';
1616
Assert::exception(
1717
fn() => Neon::decode("Hello\nWorld"),
1818
Nette\Neon\Exception::class,
19-
"Unexpected 'World' on line 2, column 1.",
19+
"Unexpected 'World' on line 2 at column 1",
2020
);
2121

2222

2323
Assert::exception(
2424
fn() => Neon::decode('"\uD801"'),
2525
Nette\Neon\Exception::class,
26-
'Invalid UTF-8 sequence \uD801 on line 1, column 1.',
26+
'Invalid UTF-8 sequence \uD801 on line 1 at column 1',
2727
);
2828

2929

3030
Assert::exception(
3131
fn() => Neon::decode("- Dave,\n- Rimmer,\n- Kryten,\n"),
3232
Nette\Neon\Exception::class,
33-
"Unexpected ',' on line 1, column 7.",
33+
"Unexpected ',' on line 1 at column 7",
3434
);
3535

3636

3737
Assert::exception(
3838
fn() => Neon::decode('item [a, b]'),
3939
Nette\Neon\Exception::class,
40-
"Unexpected ',' on line 1, column 8.",
40+
"Unexpected ',' on line 1 at column 8",
4141
);
4242

4343

4444
Assert::exception(
4545
fn() => Neon::decode('{,}'),
4646
Nette\Neon\Exception::class,
47-
"Unexpected ',' on line 1, column 2.",
47+
"Unexpected ',' on line 1 at column 2",
4848
);
4949

5050

5151
Assert::exception(
5252
fn() => Neon::decode('{a, ,}'),
5353
Nette\Neon\Exception::class,
54-
"Unexpected ',' on line 1, column 5.",
54+
"Unexpected ',' on line 1 at column 5",
5555
);
5656

5757

5858
Assert::exception(
5959
fn() => Neon::decode('"'),
6060
Nette\Neon\Exception::class,
61-
"Unexpected '\"' on line 1, column 1.",
61+
"Unexpected '\"' on line 1 at column 1",
6262
);
6363

6464

6565
Assert::exception(
6666
fn() => Neon::decode("\ta:\n b:"),
6767
Nette\Neon\Exception::class,
68-
'Invalid combination of tabs and spaces on line 2, column 2.',
68+
'Invalid combination of tabs and spaces on line 2 at column 2',
6969
);
7070

7171

7272
Assert::exception(
7373
fn() => Neon::decode("- x: 20\n - a: 10\n\tb: 10"),
7474
Nette\Neon\Exception::class,
75-
'Invalid combination of tabs and spaces on line 3, column 2.',
75+
'Invalid combination of tabs and spaces on line 3 at column 2',
7676
);
7777

7878

@@ -84,7 +84,7 @@ Assert::exception(
8484

8585
XX),
8686
Nette\Neon\Exception::class,
87-
'Bad indentation on line 3, column 2.',
87+
'Bad indentation on line 3 at column 2',
8888
);
8989

9090

@@ -94,7 +94,7 @@ Assert::exception(
9494
b:
9595
XX),
9696
Nette\Neon\Exception::class,
97-
'Bad indentation on line 2, column 3.',
97+
'Bad indentation on line 2 at column 3',
9898
);
9999

100100

@@ -104,7 +104,7 @@ Assert::exception(
104104
a: 10
105105
XX),
106106
Nette\Neon\Exception::class,
107-
'Bad indentation on line 2, column 2.',
107+
'Bad indentation on line 2 at column 2',
108108
);
109109

110110

@@ -114,7 +114,7 @@ Assert::exception(
114114
a: 10
115115
XX),
116116
Nette\Neon\Exception::class,
117-
'Bad indentation on line 2, column 4.',
117+
'Bad indentation on line 2 at column 4',
118118
);
119119

120120

@@ -124,14 +124,14 @@ Assert::exception(
124124
a: 10
125125
XX),
126126
Nette\Neon\Exception::class,
127-
'Bad indentation on line 2, column 2.',
127+
'Bad indentation on line 2 at column 2',
128128
);
129129

130130

131131
Assert::exception(
132132
fn() => Neon::decode('- x: y:'),
133133
Nette\Neon\Exception::class,
134-
"Unexpected ':' on line 1, column 7.",
134+
"Unexpected ':' on line 1 at column 7",
135135
);
136136

137137

@@ -145,7 +145,7 @@ Assert::exception(
145145
XX,
146146
),
147147
Nette\Neon\Exception::class,
148-
"Unexpected '<new line>' on line 3, column 4.",
148+
"Unexpected '<new line>' on line 3 at column 4",
149149
);
150150

151151

@@ -155,26 +155,26 @@ Assert::exception(
155155
a: 2
156156
XX),
157157
Nette\Neon\Exception::class,
158-
"Duplicated key 'a' on line 2, column 1.",
158+
"Duplicated key 'a' on line 2 at column 1",
159159
);
160160

161161

162162
Assert::exception(
163163
fn() => Neon::decode('{ []: foo }'),
164164
Nette\Neon\Exception::class,
165-
'Unacceptable key on line 1, column 3.',
165+
'Unacceptable key on line 1 at column 3',
166166
);
167167

168168

169169
Assert::exception(
170170
fn() => Neon::decode('[]: foo'),
171171
Nette\Neon\Exception::class,
172-
'Unacceptable key on line 1, column 1.',
172+
'Unacceptable key on line 1 at column 1',
173173
);
174174

175175

176176
Assert::exception(
177177
fn() => Neon::decode('{ - 1}'),
178178
Nette\Neon\Exception::class,
179-
"Unexpected '-' on line 1, column 3.",
179+
"Unexpected '-' on line 1 at column 3",
180180
);

0 commit comments

Comments
 (0)