|
48 | 48 | //! .issuer("Foo Bar".to_string())
|
49 | 49 | //! .path(create_blinded_path())
|
50 | 50 | //! .path(create_another_blinded_path())
|
51 |
| -//! .build() |
52 |
| -//! .unwrap(); |
| 51 | +//! .build()?; |
53 | 52 | //!
|
54 | 53 | //! // Encode as a bech32 string for use in a QR code.
|
55 | 54 | //! let encoded_offer = offer.to_string();
|
@@ -186,11 +185,11 @@ impl OfferBuilder {
|
186 | 185 | }
|
187 | 186 |
|
188 | 187 | /// Builds an [`Offer`] from the builder's settings.
|
189 |
| - pub fn build(self) -> Result<Offer, ()> { |
| 188 | + pub fn build(self) -> Result<Offer, SemanticError> { |
190 | 189 | // TODO: Also check for Amount::Currency
|
191 | 190 | if let Some(Amount::Currency { .. }) = self.offer.amount {
|
192 | 191 | } else if self.offer.amount_msats() > MAX_VALUE_MSAT {
|
193 |
| - return Err(()); |
| 192 | + return Err(SemanticError::InvalidAmount); |
194 | 193 | }
|
195 | 194 |
|
196 | 195 | let mut bytes = Vec::new();
|
@@ -543,6 +542,7 @@ mod tests {
|
543 | 542 | use core::time::Duration;
|
544 | 543 | use ln::features::OfferFeatures;
|
545 | 544 | use ln::msgs::MAX_VALUE_MSAT;
|
| 545 | + use offers::parse::SemanticError; |
546 | 546 | use onion_message::{BlindedHop, BlindedPath};
|
547 | 547 | use util::ser::Writeable;
|
548 | 548 | use util::string::PrintableString;
|
@@ -679,7 +679,7 @@ mod tests {
|
679 | 679 | let invalid_amount = Amount::Bitcoin { amount_msats: MAX_VALUE_MSAT + 1 };
|
680 | 680 | match OfferBuilder::new("foo".into(), pubkey(42)).amount(invalid_amount).build() {
|
681 | 681 | Ok(_) => panic!("expected error"),
|
682 |
| - Err(e) => assert_eq!(e, ()), |
| 682 | + Err(e) => assert_eq!(e, SemanticError::InvalidAmount), |
683 | 683 | }
|
684 | 684 | }
|
685 | 685 |
|
|
0 commit comments