Js Picture failed to load how to use try catch

Picture src is assigned to it through js.
Picture failed to load automatically modify its suffix.
but console will type a lot of error prompts, look unaccustomed, affecting debugging. As shown in the figure below
how to use try catch to shield error prompts?
or how to prevent an image from displaying an error message when it fails to load?


There is a onerror event in

html: . For more information, please see http://www.runoob.com/jsref/event-img-onerror.html

.

I hope I can help you

Menu