```ts
export function gradeBars(line: string, beats: number, unit: number): string[] {
  if (typeof line !== 'string') {
    throw new Error('Line must be a string');
  }
  if (![1, 2, 4, 8, 16].includes(unit)) {
    throw new Error('Unit must be one of 1, 2, 4, 8, or 16');
  }
  if (beats < 1) {
    throw new Error('Beats must be at least 1');
  }

  const barDuration = (beats * 64) / unit;
  const noteValues: { [key: string]: number } = {
    w: 64,
    h: 32,
    q: 16,
    e: 8,
    s: 4,
  };

  return line.split('|').map((bar) => {
    if (!bar.trim()) {
      throw new Error('Bar must contain notes');
    }
    const notes = bar.split(' ');
    let totalTicks = 0;

    for (const note of notes) {
      const match = note.match(/^([wheqs])(\.)?$/);
      if (!match) {
        throw new Error('Invalid note');
      }
      const [_, baseNote, dot] = match;
      const noteValue = noteValues[baseNote];
      totalTicks += noteValue + (dot ? noteValue / 2 : 0);
    }

    return totalTicks < barDuration
      ? 'short'
      : totalTicks > barDuration
      ? 'long'
      : 'exact';
  });
}
```