Shadowblade911 / MrLancer-v2

ISC License
0 stars 0 forks source link

Adding books before registering the guild throws #2

Open jcotton42 opened 2 years ago

jcotton42 commented 2 years ago

Attempting to use /addbook before /register throws

(The first 3 lines are from the Postgres container, and not the bot)

While this is user-error it should be handled more gracefully.

mrlancer-v2-postgres-1  | 2022-04-24 04:58:20.148 UTC [78] ERROR:  insert or update on table "books" violates foreign key constraint "books_guild_id_foreign"
mrlancer-v2-postgres-1  | 2022-04-24 04:58:20.148 UTC [78] DETAIL:  Key (guild_id)=(738939410275368992) is not present in table "guilds".
mrlancer-v2-postgres-1  | 2022-04-24 04:58:20.148 UTC [78] STATEMENT:  insert into "books" ("book_type", "guild_id", "title") values ($1, $2, $3)
mrlancer-v2-lancer-1    | /app/node_modules/pg-protocol/src/parser.ts:369
mrlancer-v2-lancer-1    |       name === 'notice' ? new NoticeMessage(length, messageValue) : new DatabaseError(messageValue, length, name)
mrlancer-v2-lancer-1    |                                                                     ^
mrlancer-v2-lancer-1    | error: insert into "books" ("book_type", "guild_id", "title") values ($1, $2, $3) - insert or update on table "books" violates foreign key constraint "books_guild_id_foreign"
mrlancer-v2-lancer-1    |     at Parser.parseErrorMessage (/app/node_modules/pg-protocol/src/parser.ts:369:69)
mrlancer-v2-lancer-1    |     at Parser.handlePacket (/app/node_modules/pg-protocol/src/parser.ts:188:21)
mrlancer-v2-lancer-1    |     at Parser.parse (/app/node_modules/pg-protocol/src/parser.ts:103:30)
mrlancer-v2-lancer-1    |     at Socket.<anonymous> (/app/node_modules/pg-protocol/src/index.ts:7:48)
mrlancer-v2-lancer-1    |     at Socket.emit (node:events:526:28)
mrlancer-v2-lancer-1    |     at Socket.emit (node:domain:475:12)
mrlancer-v2-lancer-1    |     at addChunk (node:internal/streams/readable:315:12)
mrlancer-v2-lancer-1    |     at readableAddChunk (node:internal/streams/readable:289:9)
mrlancer-v2-lancer-1    |     at Socket.Readable.push (node:internal/streams/readable:228:10)
mrlancer-v2-lancer-1    |     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
jcotton42 commented 2 years ago

Implementing #11 would fix this as well.