```ts
export function gradeBars(line: string, beats: number, unit: number): string[] {
  if (typeof line !== 'string') {
    throw new Error('Input must be a string');
  }
  if (!Number.isInteger(beats) || beats < 1) {
    throw new Error('Beats must be an integer greater than or equal to 1');
  }
  if (![1, 2, 4, 8, 16].includes(unit)) {
    throw new Error('Unit must be one of 1, 2, 4, 8, or 16');
  }

  const result: string[] = [];
  const barTicks = beats * 64 / unit;

  for (const bar of line.split('|')) {
    if (bar.trim() === '') {
      throw new Error('Bar cannot be empty');
    }
    let ticks = 0;
    for (const note of bar.split(' ')) {
      switch (note) {
        case 'w': ticks += 64; break;
        case 'h': ticks += 32; break;
        case 'q': ticks += note.endsWith('.') ? 24 : 16; break;
        case 'e': ticks += note.endsWith('.') ? 12 : 8; break;
        case 's': ticks += note.endsWith('.') ? 6 : 4; break;
        default: throw new Error('Invalid note');
      }
    }
    if (ticks < barTicks) {
      result.push('short');
    } else if (ticks === barTicks) {
      result.push('exact');
    } else {
      result.push('long');
    }
  }

  return result;
}
```