Open
Description
Following #141 (and #142), it's been put under the light that when the library is incorrectly used, it doesn't communicate the issue in a very user friendly manner
<html lang=\"en\">
<head>
<meta charset=\"utf-8\">
<title>Error</title>
</head>
<body>
<pre>AssertionError [ERR_ASSERTION]: Invalid 'grant_type' type<br> at new AssertionError (node:internal/assert/assertion_error:466:5)<br> at assertIsString (C:\\_work\\oauth2-mock-server\\src\\lib\\helpers.ts:33:11)<br> at assertIsValidTokenRequest (C:\\_work\\oauth2-mock-server\\src\\lib\\helpers.ts:64:3)<br> at fn (C:\\_work\\oauth2-mock-server\\src\\lib\\oauth2-service.ts:186:7)<br> at Layer.handle_request (C:\\_work\\oauth2-mock-server\\node_modules\\express\\lib\\router\\layer.js:95:5)<br> at next (C:\\_work\\oauth2-mock-server\\node_modules\\express\\lib\\router\\route.js:137:13)<br> at fn (C:\\_work\\oauth2-mock-server\\node_modules\\body-parser\\lib\\types\\urlencoded.js:100:7)<br> at Layer.handle_request (C:\\_work\\oauth2-mock-server\\node_modules\\express\\lib\\router\\layer.js:95:5)<br> at next (C:\\_work\\oauth2-mock-server\\node_modules\\express\\lib\\router\\route.js:137:13)<br> at Route.dispatch (C:\\_work\\oauth2-mock-server\\node_modules\\express\\lib\\router\\route.js:112:3)</pre>
</body>
</html>
Rather than throwing AssertionErrors and letting Express default error handler deal with them, it might be cleaner to return 400 responses with a meaningful error message.
Activity