Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

connor hoare
7,932 PointsI literally am confused y the question and don't have a clue what to do here.
Please assist me what steps I should take and what to change the catch statements to
enum ParserError: Error {
case emptyDictionary
case invalidKey
}
struct Parser {
var data: [String : String?]?
func parse() throws {
guard let data = data else {
throw ParserError.emptyDictionary
}
guard data["somekey"] != nil else {
throw ParserError.invalidKey
}
}
}
let data: [String : String?]? = ["someKey": nil]
do {
let parser = Parser(data: data)
try parser.parse()
} catch ParserError.emptyDictionary {
} catch ParserError.invalidKey {
}
1 Answer

tromben98
13,273 PointsHi! here is the solution to the challenge:
[Moderator redacted]

Michael Hulet
47,842 PointsHey tromben98!
For future reference, it's frowned upon in the Community to post code that can be copied and pasted and just work without any explanation of why it works and why it's the correct answer. As such, I've redacted your code here. If you'd like, feel free to re-post your solution, but be sure to give a thorough explanation of why it works and why it's the correct answer. Thanks for helping out in the Community!
Michael Hulet
47,842 PointsMichael Hulet
47,842 PointsYour code as posted passes all 3 steps of the challenge when I paste it in. What is your question, exactly?