fix: enhance error and warning messages with localization support
(cherry picked from commit 576763fe5b26e3a5b3706e806ebd33bbb9234b14)
This commit is contained in:
parent
78fdd51104
commit
d8477ef396
@ -72,7 +72,10 @@ export function getScript(doctype, view = 'Form') {
|
|||||||
if (isChildDoctype) {
|
if (isChildDoctype) {
|
||||||
if (!controllers.length) {
|
if (!controllers.length) {
|
||||||
console.error(
|
console.error(
|
||||||
`⚠️ No class found for doctype: ${doctype}, it is mandatory to have a class for the parent doctype. it can be empty, but it should be present.`,
|
__(
|
||||||
|
'⚠️ No class found for doctype: {0}, it is mandatory to have a class for the parent doctype. it can be empty, but it should be present.',
|
||||||
|
[doctype],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -92,7 +95,7 @@ export function getScript(doctype, view = 'Form') {
|
|||||||
controllers.push(instance)
|
controllers.push(instance)
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load form controller:', err)
|
console.error(__('Failed to load form controller: {0}', [err]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,14 +148,17 @@ export function getScript(doctype, view = 'Form') {
|
|||||||
idx = idx || instance.currentRowIdx
|
idx = idx || instance.currentRowIdx
|
||||||
|
|
||||||
if (!data[parentField]) {
|
if (!data[parentField]) {
|
||||||
console.warn(`⚠️ No data found for parent field: ${parentField}`)
|
console.warn(__('⚠️ No data found for parent field: {0}', [parentField]))
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const row = data[parentField].find((r) => r.idx === idx)
|
const row = data[parentField].find((r) => r.idx === idx)
|
||||||
|
|
||||||
if (!row) {
|
if (!row) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`⚠️ No row found for idx: ${idx} in parent field: ${parentField}`,
|
__('⚠️ No row found for idx: {0} in parent field: {1}', [
|
||||||
|
idx,
|
||||||
|
parentField,
|
||||||
|
]),
|
||||||
)
|
)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -197,7 +203,9 @@ export function getScript(doctype, view = 'Form') {
|
|||||||
if (prop === 'trigger') {
|
if (prop === 'trigger') {
|
||||||
if ('trigger' in data) {
|
if ('trigger' in data) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`⚠️ Avoid using "trigger" as a field name — it conflicts with the built-in trigger() method.`,
|
__(
|
||||||
|
'⚠️ Avoid using "trigger" as a field name — it conflicts with the built-in trigger() method.',
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +214,9 @@ export function getScript(doctype, view = 'Form') {
|
|||||||
if (typeof method === 'function') {
|
if (typeof method === 'function') {
|
||||||
return method.apply(instance, args)
|
return method.apply(instance, args)
|
||||||
} else {
|
} else {
|
||||||
console.warn(`⚠️ Method "${methodName}" not found in class.`)
|
console.warn(
|
||||||
|
__('⚠️ Method "{0}" not found in class.', [methodName]),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user