You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (let rawCandidate of rawCandidates) {
let candidate = designSystem.parseCandidate(rawCandidate)
if (candidate === null) {
if (onInvalidCandidate) {
onInvalidCandidate(rawCandidate);
} else {
throw new Error(Invalid candidate: "${rawCandidate}");
}
continue; // Bail, invalid candidate
}
candidates.set(candidate, rawCandidate);
}
// ...
}
export function compileAstNodes(rawCandidate: string, designSystem: DesignSystem) {
let candidate = designSystem.parseCandidate(rawCandidate);
if (candidate === null) {
throw new Error(Invalid candidate: "${rawCandidate}");
}
// ...
}
Specific Error Messages:
Problem: Current error handling mainly involves calling the onInvalidCandidate callback function to handle invalid candidates, and printing corresponding error messages to the console.
Optimization Suggestion: Directly throw an error with specific error messages when encountering invalid candidates, providing better insight into what went wrong.
The text was updated successfully, but these errors were encountered:
We appreciate your effort in raising this issue. To ensure clarity in understanding your situation, we kindly request you recreate the issue using one of our templates.
Your collaboration will help us in providing you with effective assistance.
export function compileCandidates(
rawCandidates: Iterable,
designSystem: DesignSystem,
{ onInvalidCandidate }: { onInvalidCandidate?: (candidate: string) => void } = {},
) {
// ...
for (let rawCandidate of rawCandidates) {
let candidate = designSystem.parseCandidate(rawCandidate)
if (candidate === null) {
if (onInvalidCandidate) {
onInvalidCandidate(rawCandidate);
} else {
throw new Error(
Invalid candidate: "${rawCandidate}"
);}
continue; // Bail, invalid candidate
}
candidates.set(candidate, rawCandidate);
}
// ...
}
export function compileAstNodes(rawCandidate: string, designSystem: DesignSystem) {
let candidate = designSystem.parseCandidate(rawCandidate);
if (candidate === null) {
throw new Error(
Invalid candidate: "${rawCandidate}"
);}
// ...
}
onInvalidCandidate
callback function to handle invalid candidates, and printing corresponding error messages to the console.The text was updated successfully, but these errors were encountered: