Skip to content

Commit

Permalink
Make it easier to see why requests are invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Dec 12, 2023
1 parent 5f5f2a6 commit b68a9e0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpClient, HttpServer, Runtime } from '@effect/platform-node'
import { Schema } from '@effect/schema'
import { Schema, TreeFormatter } from '@effect/schema'
import { Effect, Layer } from 'effect'
import { createServer } from 'node:http'
import * as CoarNotify from './CoarNotify.js'
Expand Down Expand Up @@ -80,7 +80,16 @@ const serve = HttpServer.router.empty.pipe(
return yield* _(HttpServer.response.empty({ status: 201 }))
}).pipe(
Effect.catchTags({
ParseError: () => HttpServer.response.empty({ status: 400 }),
ParseError: error =>
Effect.gen(function* (_) {
yield* _(
Effect.logInfo('Invalid request').pipe(
Effect.annotateLogs({ message: TreeFormatter.formatErrors(error.errors) }),
),
)

return HttpServer.response.empty({ status: 400 })
}),
RedisError: error =>
Effect.gen(function* (_) {
yield* _(
Expand Down

0 comments on commit b68a9e0

Please sign in to comment.