Skip to content

Commit 95b3644

Browse files
committed
add more context to to errors
1 parent 43dfe27 commit 95b3644

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

lib/plugins/anvil.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function inject (bot) {
1212
async function openAnvil (anvilBlock) {
1313
const anvil = await bot.openBlock(anvilBlock)
1414
if (!matchWindowType(anvil)) {
15-
throw new Error('This is not a anvil-like window')
15+
throw new Error('Not a anvil-like window: ' + JSON.stringify(anvil))
1616
}
1717

1818
function err (name) {

lib/plugins/chat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function inject (bot, options) {
144144
function chatWithHeader (header, message) {
145145
if (typeof message === 'number') message = message.toString()
146146
if (typeof message !== 'string') {
147-
throw new Error('Incorrect type! Should be a string or number.')
147+
throw new Error('Chat message type must be a string or number: ' + typeof message)
148148
}
149149

150150
if (!header && message.startsWith('/')) {

lib/plugins/chest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function inject (bot) {
2323
throw new Error('containerToOpen is neither a block nor an entity')
2424
}
2525

26-
if (!matchWindowType(chest)) { throw new Error('Non-container window used as a container') }
26+
if (!matchWindowType(chest)) { throw new Error('Non-container window used as a container: ' + JSON.stringify(chest)) }
2727
return chest
2828
}
2929

lib/plugins/craft.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function inject (bot) {
1212
assert.ok(recipe)
1313
count = parseInt(count ?? 1, 10)
1414
if (recipe.requiresTable && !craftingTable) {
15-
throw new Error('recipe requires craftingTable')
15+
throw new Error('Recipe requires craftingTable, but one was not supplied: ' + JSON.stringify(recipe))
1616
}
1717

1818
try {
@@ -41,7 +41,7 @@ function inject (bot) {
4141
windowCraftingTable = window
4242
}
4343
if (!windowCraftingTable.type.startsWith('minecraft:crafting')) {
44-
throw new Error('crafting: non craftingTable used as craftingTable')
44+
throw new Error('crafting: non craftingTable used as craftingTable: ' + windowCraftingTable.type)
4545
}
4646
await startClicking(windowCraftingTable, 3, 3)
4747
} else {

lib/plugins/enchantment_table.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function inject (bot) {
99
let ready = false
1010
const enchantmentTable = await bot.openBlock(enchantmentTableBlock)
1111
if (!enchantmentTable.type.startsWith('minecraft:enchant')) {
12-
throw new Error('This is not an enchantment table')
12+
throw new Error('Expected minecraft:enchant when opening table but got ' + enchantmentTable.type)
1313
}
1414

1515
resetEnchantmentOptions()

lib/plugins/villager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function inject (bot, { version }) {
7878
bot._client.on(tradeListPacket, gotTrades)
7979
const villager = await villagerPromise
8080
if (villager.type !== 'minecraft:villager' && villager.type !== 'minecraft:merchant') {
81-
throw new Error('This is not a villager')
81+
throw new Error('Expected minecraft:villager or minecraft:mechant type, but got ' + villager.type)
8282
}
8383

8484
villager.trades = null

0 commit comments

Comments
 (0)