Skip to content

Commit

Permalink
feat: JuiceMakerError 에러 타입 추가 #1
Browse files Browse the repository at this point in the history
  • Loading branch information
just1103 committed Oct 19, 2021
1 parent 26bce53 commit 1504f91
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions JuiceMaker/JuiceMaker/Model/JuiceMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ struct Juice {
// 쥬스 메이커 타입
struct JuiceMaker {

enum JuiceMakerError: LocalizedError {
case inValidMenuChoice

var description: String {
switch self {
case .inValidMenuChoice:
return "메뉴에 없습니다. 다시 선택해주세요."
}
}
}

var store = FruitStore()

typealias ingredient = (fruit: Fruit.FruitName, count: Int)
Expand All @@ -48,7 +59,7 @@ struct JuiceMaker {

mutating func findRecipe(of juiceName: Juice.JuiceName) throws -> [ingredient] {
guard let foundRecipe = recipe[juiceName] else {
throw
throw JuiceMakerError.inValidMenuChoice
}
return foundRecipe
}
Expand All @@ -63,8 +74,8 @@ struct JuiceMaker {
do {
let foundRecipe = try findRecipe(of: juiceName)
blendIngredient(by: foundRecipe)
} catch {

} catch JuiceMakerError.inValidMenuChoice {
print(JuiceMakerError.inValidMenuChoice.description)
} catch {
print(error)
}
Expand Down

0 comments on commit 1504f91

Please sign in to comment.