Fix substr calling sequence in error message