I have a simple channel that formats the passed parameters into a date format. If this conversion is incorrect, it causes an error. But it never throws an error in a catch block.
import {PipeTransform, Pipe} from 'angular2/core';
@Pipe({
name: 'formatDate'
})
export class FormatDatePipe implements PipeTransform {
transform(value: string): any {
let date: string;
try {
date = new Date(value).toLocaleDateString();
}
catch (Exception) {
return value;
}
finally {
return date;
}
}
Why do catch locks fail even if an invalid date is passed?
source
share