badges: Fix regression introduced in 77dd2a97
A regression related to badges URLs was introduced in 77dd2a97 that broke the rendering of badges for a qualified SWHID (see https://jtcam.episciences.org/12389 for instance).
Reorder badges URL patterns as URL pattern taking a SWHID as argument should be checked prior the one taking object_type and object_id as arguments (as a qualified SWHID can also match that URL pattern).
Return more meaningful HTTP status code when an error occurs when attempting to generate a badge.