| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| HintErrorHandler |
|
| 1.6666666666666667;1.667 |
| 1 | /* | |
| 2 | * This file is part of dependency-check-core. | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | * | |
| 16 | * Copyright (c) 2016 Jeremy Long. All Rights Reserved. | |
| 17 | */ | |
| 18 | package org.owasp.dependencycheck.xml.hints; | |
| 19 | ||
| 20 | import org.owasp.dependencycheck.utils.XmlUtils; | |
| 21 | import org.slf4j.Logger; | |
| 22 | import org.slf4j.LoggerFactory; | |
| 23 | import org.xml.sax.ErrorHandler; | |
| 24 | import org.xml.sax.SAXException; | |
| 25 | import org.xml.sax.SAXParseException; | |
| 26 | ||
| 27 | /** | |
| 28 | * An XML parsing error handler. | |
| 29 | * | |
| 30 | * @author Jeremy Long | |
| 31 | */ | |
| 32 | 5 | public class HintErrorHandler implements ErrorHandler { |
| 33 | ||
| 34 | /** | |
| 35 | * The logger. | |
| 36 | */ | |
| 37 | 1 | private static final Logger LOGGER = LoggerFactory.getLogger(HintErrorHandler.class); |
| 38 | ||
| 39 | /** | |
| 40 | * Logs warnings. | |
| 41 | * | |
| 42 | * @param ex the warning to log | |
| 43 | * @throws SAXException is never thrown | |
| 44 | */ | |
| 45 | @Override | |
| 46 | public void warning(SAXParseException ex) throws SAXException { | |
| 47 | 0 | LOGGER.debug("", ex); |
| 48 | 0 | } |
| 49 | ||
| 50 | /** | |
| 51 | * Handles errors. | |
| 52 | * | |
| 53 | * @param ex the error to handle | |
| 54 | * @throws SAXException is always thrown | |
| 55 | */ | |
| 56 | @Override | |
| 57 | public void error(SAXParseException ex) throws SAXException { | |
| 58 | 0 | throw new SAXException(XmlUtils.getPrettyParseExceptionInfo(ex)); |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * Handles fatal exceptions. | |
| 63 | * | |
| 64 | * @param ex a fatal exception | |
| 65 | * @throws SAXException is always | |
| 66 | */ | |
| 67 | @Override | |
| 68 | public void fatalError(SAXParseException ex) throws SAXException { | |
| 69 | 0 | throw new SAXException(XmlUtils.getPrettyParseExceptionInfo(ex)); |
| 70 | } | |
| 71 | } |