@@ -186,17 +186,17 @@ function serialize(name, val, opt) {
186
186
var enc = ( opt && opt . encode ) || encodeURIComponent ;
187
187
188
188
if ( typeof enc !== 'function' ) {
189
- throw new TypeError ( 'option encode is invalid' ) ;
189
+ throw new TypeError ( 'option encode is invalid: ' + enc ) ;
190
190
}
191
191
192
192
if ( ! cookieNameRegExp . test ( name ) ) {
193
- throw new TypeError ( 'argument name is invalid' ) ;
193
+ throw new TypeError ( 'argument name is invalid: ' + name ) ;
194
194
}
195
195
196
196
var value = enc ( val ) ;
197
197
198
198
if ( ! cookieValueRegExp . test ( value ) ) {
199
- throw new TypeError ( 'argument val is invalid' ) ;
199
+ throw new TypeError ( 'argument val is invalid: ' + value ) ;
200
200
}
201
201
202
202
var str = name + '=' + value ;
@@ -206,23 +206,23 @@ function serialize(name, val, opt) {
206
206
var maxAge = Math . floor ( opt . maxAge ) ;
207
207
208
208
if ( ! isFinite ( maxAge ) ) {
209
- throw new TypeError ( 'option maxAge is invalid' )
209
+ throw new TypeError ( 'option maxAge is invalid: ' + opt . maxAge )
210
210
}
211
211
212
212
str += '; Max-Age=' + maxAge ;
213
213
}
214
214
215
215
if ( opt . domain ) {
216
216
if ( ! domainValueRegExp . test ( opt . domain ) ) {
217
- throw new TypeError ( 'option domain is invalid' ) ;
217
+ throw new TypeError ( 'option domain is invalid: ' + opt . domain ) ;
218
218
}
219
219
220
220
str += '; Domain=' + opt . domain ;
221
221
}
222
222
223
223
if ( opt . path ) {
224
224
if ( ! pathValueRegExp . test ( opt . path ) ) {
225
- throw new TypeError ( 'option path is invalid' ) ;
225
+ throw new TypeError ( 'option path is invalid: ' + opt . path ) ;
226
226
}
227
227
228
228
str += '; Path=' + opt . path ;
@@ -232,7 +232,7 @@ function serialize(name, val, opt) {
232
232
var expires = opt . expires
233
233
234
234
if ( ! isDate ( expires ) || isNaN ( expires . valueOf ( ) ) ) {
235
- throw new TypeError ( 'option expires is invalid' ) ;
235
+ throw new TypeError ( 'option expires is invalid: ' + expires ) ;
236
236
}
237
237
238
238
str += '; Expires=' + expires . toUTCString ( )
@@ -265,7 +265,7 @@ function serialize(name, val, opt) {
265
265
str += '; Priority=High'
266
266
break
267
267
default :
268
- throw new TypeError ( 'option priority is invalid' )
268
+ throw new TypeError ( 'option priority is invalid: ' + priority )
269
269
}
270
270
}
271
271
@@ -287,7 +287,7 @@ function serialize(name, val, opt) {
287
287
str += '; SameSite=None' ;
288
288
break ;
289
289
default :
290
- throw new TypeError ( 'option sameSite is invalid' ) ;
290
+ throw new TypeError ( 'option sameSite is invalid: ' + sameSite ) ;
291
291
}
292
292
}
293
293
0 commit comments