Bản mẫu:TryCatch
This metatemplate simplifies implementing fallback output if an error occurs due to incorrect input. It returns the first parameter if it does not contain an error (using the #iferror parser function), and the second parameter (or the empty string) otherwise.
Cách sử dụng[sửa mã nguồn]
{{TryCatch|{{#expr: 1/2}}|Đầu vào không chính xác}}
→ 0.5{{TryCatch|{{#expr: 1/0}}|Đầu vào không chính xác}}
→ Đầu vào không chính xác
Xem thêm[sửa mã nguồn]
- {{Error}}: bản mẫu để báo hiệu một lỗi
- mw:Help:Extension:ParserFunctions##iferror