Bug 36309: Make create_superlibrarian.pl output more useful
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 13 Mar 2024 17:56:27 +0000 (14:56 -0300)
committerKatrin Fischer <katrin.fischer@bsz-bw.de>
Mon, 22 Apr 2024 06:57:35 +0000 (08:57 +0200)
commitdf1f5da6734fe94b62e4b50fec9e7fadbfce794b
treed74dace31abfa0669e3cae6841d8700c7c3a0270
parentba0f7f737882728fba2221a5d8dd02946980ef1b
Bug 36309: Make create_superlibrarian.pl output more useful

In situations in which you are not familiar with all the Koha settings,
and table structure, the fact this script just fails telling there's a
broken FK is just not practical.

We should capture those exceptions and display a useful message instead.

This script does that. It adds some validations and some exception
handling too. It prints a nice message about the bad value the user
passed, and the valid values too!

To test:
1. Run this on a fresh KTD:
   $ ktd --shell
  k$ perl  misc/devel/create_superlibrarian.pl \
      --userid tcohen \
      --password tomasito \
      --cardnumber 123456789 \
      --categorycode POT \
      --branchcode ATO
=> FAIL: It explodes with a MySQL exception message!
2. Apply this patch
3. Repeat 1
=> SUCCESS: It tells you which value is wrong and what values you can
pick to make the command work
4. Pick a valid value, and repeat
=> SUCCESS: Now the other value is wrong, a nice message is displayed!
5. Fix with a valid value and repeat
=> SUCCESS: Patron created!
6. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
misc/devel/create_superlibrarian.pl