Error messages should be specific, contextual, and include relevant information to aid debugging and user understanding. Avoid generic messages like “invalid syntax” in favor of descriptive explanations that specify what was expected, what was found, and include the problematic data when helpful.

Key practices:

Example transformation:

// Before: Generic and unhelpful
if ch > 9 {
    return error('strconv.atoi: parsing "${s}": invalid syntax')
}

// After: Specific and informative  
if ch > 9 {
    return error('strconv.atoi: parsing "${s}": character `${s[i]}` is not a valid digit')
}

This approach significantly improves the debugging experience and helps users understand exactly what went wrong and how to fix it.