Bản mẫu:TryCatch
Giao diện
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
{{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
- {{Error}}: bản mẫu để báo hiệu một lỗi
- mw:Help:Extension:ParserFunctions##iferror