@jakesidsmith/tsb
Version:
Dead simple TypeScript bundler, watcher, dev server, transpiler, and polyfiller
18 lines (13 loc) • 335 B
text/typescript
import { ValidationError } from 'yup';
export const getErrorMessages = (error: unknown): string => {
if (typeof error === 'string') {
return error;
}
if (error instanceof ValidationError) {
return error.errors.join('\n');
}
if (error instanceof Error) {
return error.message;
}
return 'Unknown error';
};