2024-08-30 11:51:36 +02:00
|
|
|
fun FishError(message) {
|
2024-07-25 16:57:28 +02:00
|
|
|
return HogError('FishError', message)
|
|
|
|
}
|
2024-08-30 11:51:36 +02:00
|
|
|
fun FoodError(message) {
|
2024-07-25 16:57:28 +02:00
|
|
|
return HogError('FoodError', message)
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
throw FishError('You forgot to feed your fish')
|
|
|
|
} catch (e: FoodError) {
|
|
|
|
print(f'Problem with your food: {e.message}')
|
|
|
|
} catch (e: FishError) {
|
|
|
|
print(f'Problem with your fish: {e.message}')
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
throw FoodError('Your fish are hungry')
|
|
|
|
} catch (e: FoodError) {
|
|
|
|
print(f'Problem with your food: {e.message}')
|
|
|
|
} catch (e: FishError) {
|
|
|
|
print(f'Problem with your fish: {e.message}')
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
throw NotImplementedError('Your fish are hungry')
|
|
|
|
} catch (e: FoodError) {
|
|
|
|
print(f'Problem with your food: {e.message}')
|
|
|
|
} catch {
|
|
|
|
print(f'Unknown problem: {e}')
|
|
|
|
}
|