Jyro 0.7.0, with a breaking change
In this release, we've refactored how runtime exceptions carry error information to enable proper message formatting and localization support.
What Changed
The JyroRuntimeException constructor signature changed from accepting a pre-formatted error message to accepting raw template arguments:
// Before (v1.x)
public JyroRuntimeException(
MessageCode code,
int lineNumber,
int columnPosition,
string errorMessage)
// After (v2.0)
public JyroRuntimeException(
MessageCode code,
int lineNumber,
int columnPosition,
params string[] arguments)
A new Arguments property exposes these raw values for template substitution.
Why This Change
Previously, error messages were formatted at the throw site, then formatted again by MessageProvider, causing duplicated text like:
Cannot access index on type 'Cannot access index on type 'String''
The new design separates concerns: exceptions carry structured diagnostic data, while IMessageProvider handles all formatting. This also enables consumers to implement custom message providers for localization.
Migration Guide
If you're catching JyroRuntimeException and reading Message:
The Message property now contains comma-joined arguments rather than the formatted error text. To get a properly formatted message, use IMessageProvider.Format():
// Before
catch (JyroRuntimeException ex)
{
Logger.Error(ex.Message);
}
// After
catch (JyroRuntimeException ex)
{
var provider = new MessageProvider();
var message = new Message(
ex.Code,
ex.LineNumber,
ex.ColumnPosition,
MessageSeverity.Error,
ProcessingStage.Execution,
ex.Arguments.ToArray());
Logger.Error(provider.Format(message));
}
If you're throwing JyroRuntimeException with the 4-parameter constructor:
Pass raw argument values instead of a pre-formatted string:
// Before
throw new JyroRuntimeException(
MessageCode.InvalidIndexTarget,
line, column,
$"Cannot access index on type '{value.Type}'");
// After
throw new JyroRuntimeException(
MessageCode.InvalidIndexTarget,
line, column,
value.Type.ToString());
If you're using the simple constructors:
No changes required. The JyroRuntimeException(string) and JyroRuntimeException(string, Exception) constructors remain unchanged.