Skip to content

Commit

Permalink
fix: catch control lookup error so that we can output the custom cont…
Browse files Browse the repository at this point in the history
…rol specific error
  • Loading branch information
lucasnetau committed Jul 4, 2024
1 parent c180c9f commit 7aa72ce
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/js/customControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,24 @@ export default class customControls {
// if there is no template defined for this type, check if we already have this type/subtype registered
if (!templates[type]) {
// check that this type is already registered
const controlClass = control.getClass(type, field.subtype)
if (!controlClass) {
super.error(
try {
const controlClass = control.getClass(type, field.subtype)

// generate a random key & map the settings against it
lookup = field.datatype ? field.datatype : `${type}-${Math.floor(Math.random() * 9000 + 1000)}`

this.customRegister[lookup] = jQuery.extend(field, {
type: type,
class: controlClass,
})
} catch(e) {
control.error(
'Error while registering custom field: ' +
type +
(field.subtype ? ':' + field.subtype : '') +
'. Unable to find any existing defined control or template for rendering.',
)
continue
}

// generate a random key & map the settings against it
lookup = field.datatype ? field.datatype : `${type}-${Math.floor(Math.random() * 9000 + 1000)}`

this.customRegister[lookup] = jQuery.extend(field, {
type: type,
class: controlClass,
})
} else {
//Map the field definition into the templated control class
const controlClass = this.templateControlRegister[type]
Expand Down

0 comments on commit 7aa72ce

Please sign in to comment.