Skip to main content

Practice ยท 2 of 4

ATM with a custom exception

CHALLENGE
Difficulty: beginner+25 XP

Implement nested class Solution.InsufficientFundsException : Exception with a public decimal Missing { get; } (constructor (decimal missing) passing a message to base and storing it), plus static decimal Withdraw(decimal balance, decimal amount) throwing ArgumentException for non-positive amounts and InsufficientFundsException when amount > balance (Missing = amount โˆ’ balance); success returns the new balance.

Back to lesson: Practice: Error handling workout