Error Handling
Planned for 6.4.x
ℹ️ Available currently in 6.4.0-pre-release.
You can set error handler for documentation builder.
// throw (default)
builder.setErrorHandler((e) => { throw e; });
// log
builder.setErrorHandler((e) => { console.error("Doc build failed:", e); });
// log and throw
builder.setErrorHandler((e) => { console.error("Doc build failed:", e); throw e; });
// Silent
builder.setErrorHandler((e) => { });
There are separate error classes. They all derive from Core.MusicError.
Core.InvalidArgErrorAudio.AudioErrorScore.ScoreErrorTheory.KeySignatureErrorTheory.TimeSignatureErrorTheory.NoteErrorTheory.NoteDurationErrorTheory.ScaleError
Catch errors.
try {
// Do your music stuff here.
}
catch (e) {
if(e instanceof Core.MusicError) {
// Catch all errors.
}
}
6.3.x and Earlier
Catch errors.
try {
// Do your music stuff here.
}
catch (e) {
if(e instanceof Core.MusicError) {
// Catch all music errors.
}
}