use std::num::{ParseFloatError, ParseIntError};
use std::str::ParseBoolError;
use thiserror::Error;
use crate::protocol::errors::ParseError;
use crate::protocol::MessageFieldParsingError;
#[derive(Debug, Clone, Error)]
pub enum XmlParseError {
#[error("incorrect tags order: tag `{after}` appears inside tag {before:?}")]
InvalidTagsOrder {
before: Option<String>,
after: String,
},
#[error("incorrect closing tag: opened with `{opened_with:?}` but closed with {closed_with}")]
InvalidClosingTag {
opened_with: Option<String>,
closed_with: String,
},
#[error("impossible to parse dialect version: {0:?}")]
VersionParseFailed(ParseIntError),
#[error("impossible to parse dialect ID: {0:?}")]
DialectIdParseFailed(ParseIntError),
#[error("found `<entry>` tag outside of `<enum>` tag")]
EnumEntryWithoutEnum,
#[error("impossible to parse enum entry value: {0:?}")]
EnumEntryValueParseFailed(ParseIntError),
#[error("found `<param>` tag outside of `<enum>` tag")]
MavCmdParamWithoutEnumEntry,
#[error("invalid `hasLocation` field value: {0:?}")]
EnumEntryMavCmdFlagsInvalidHasLocation(ParseBoolError),
#[error("invalid `isDestination` field value in enum entry: {0:?}")]
EnumEntryMavCmdFlagsInvalidIsDestination(ParseBoolError),
#[error("invalid `missionOnly` field value in enum entry: {0:?}")]
EnumEntryMavCmdFlagsInvalidMissionOnly(ParseBoolError),
#[error("invalid `index` field value in enum entry param: {0:?}")]
EnumEntryMavCmdParamInvalidIndex(ParseIntError),
#[error("invalid `decimalPlaces` field value in enum entry param: {0:?}")]
EnumEntryMavCmdParamInvalidDecimalPlaces(ParseIntError),
#[error("invalid `increment` field value in enum entry param: {0:?}")]
EnumEntryMavCmdParamInvalidIncrement(ParseError),
#[error("invalid `minValue` field value in enum entry param: {0:?}")]
EnumEntryMavCmdParamInvalidMinValue(ParseError),
#[error("invalid `maxValue` field value in enum entry param: {0:?}")]
EnumEntryMavCmdParamInvalidMaxValue(ParseError),
#[error("invalid `reserved` field value in enum entry param: {0:?}")]
EnumEntryMavCmdParamInvalidReserved(ParseBoolError),
#[error("invalid `default` field value in enum entry param: {0:?}")]
EnumEntryMavCmdParamInvalidDefaultValue(ParseError),
#[error("invalid message ID: {0:?}")]
InvalidMessageId(ParseIntError),
#[error("invalid message field: {0:?}")]
InvalidMessageField(MessageFieldParsingError),
#[error("invalid message field `instance` field: {0:?}")]
InvalidMessageFieldInstance(ParseBoolError),
#[error("invalid deprecated since date format: {0}")]
InvalidDeprecatedSinceDateFormat(String),
#[error("invalid deprecated since year: {0}")]
InvalidDeprecatedSinceYear(ParseIntError),
#[error("invalid deprecated since month: {0}")]
InvalidDeprecatedSinceMonth(ParseIntError),
#[error("invalid value")]
InvalidValue(ParseError),
#[error("value is specified by incorrect integer representation: {0:?}")]
InvalidIntValue(ParseIntError),
#[error("value is specified by incorrect floating point representation: {0:?}")]
InvalidFloatValue(ParseFloatError),
#[error("invalid units: {0:?}")]
UnitsError(ParseError),
#[error("found `<field>` tag outside of `<message>` tag")]
MessageFieldWithoutMessage,
#[error("found `<extensions>` tag outside of `<message>` tag")]
MessageExtensionsWithoutMessage,
#[error("found `<description>` tag outside of any appropriate tag")]
DescriptionWithoutSubject,
#[error("found `<deprecated>` tag outside of any appropriate tag")]
DeprecationWithoutSubject,
#[error("found `<wip>` tag outside of any appropriate tag")]
WipWithoutSubject,
}