{-# language CPP #-}
-- No documentation found for Chapter "Exception"
module Vulkan.Exception  (VulkanException(..)) where

import GHC.Exception.Type (Exception(..))
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
-- | This exception is thrown from calls to marshalled Vulkan commands
-- which return a negative VkResult.
newtype VulkanException = VulkanException { VulkanException -> Result
vulkanExceptionResult :: Result }
  deriving (VulkanException -> VulkanException -> Bool
(VulkanException -> VulkanException -> Bool)
-> (VulkanException -> VulkanException -> Bool)
-> Eq VulkanException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VulkanException -> VulkanException -> Bool
== :: VulkanException -> VulkanException -> Bool
$c/= :: VulkanException -> VulkanException -> Bool
/= :: VulkanException -> VulkanException -> Bool
Eq, Eq VulkanException
Eq VulkanException =>
(VulkanException -> VulkanException -> Ordering)
-> (VulkanException -> VulkanException -> Bool)
-> (VulkanException -> VulkanException -> Bool)
-> (VulkanException -> VulkanException -> Bool)
-> (VulkanException -> VulkanException -> Bool)
-> (VulkanException -> VulkanException -> VulkanException)
-> (VulkanException -> VulkanException -> VulkanException)
-> Ord VulkanException
VulkanException -> VulkanException -> Bool
VulkanException -> VulkanException -> Ordering
VulkanException -> VulkanException -> VulkanException
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: VulkanException -> VulkanException -> Ordering
compare :: VulkanException -> VulkanException -> Ordering
$c< :: VulkanException -> VulkanException -> Bool
< :: VulkanException -> VulkanException -> Bool
$c<= :: VulkanException -> VulkanException -> Bool
<= :: VulkanException -> VulkanException -> Bool
$c> :: VulkanException -> VulkanException -> Bool
> :: VulkanException -> VulkanException -> Bool
$c>= :: VulkanException -> VulkanException -> Bool
>= :: VulkanException -> VulkanException -> Bool
$cmax :: VulkanException -> VulkanException -> VulkanException
max :: VulkanException -> VulkanException -> VulkanException
$cmin :: VulkanException -> VulkanException -> VulkanException
min :: VulkanException -> VulkanException -> VulkanException
Ord, ReadPrec [VulkanException]
ReadPrec VulkanException
Int -> ReadS VulkanException
ReadS [VulkanException]
(Int -> ReadS VulkanException)
-> ReadS [VulkanException]
-> ReadPrec VulkanException
-> ReadPrec [VulkanException]
-> Read VulkanException
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS VulkanException
readsPrec :: Int -> ReadS VulkanException
$creadList :: ReadS [VulkanException]
readList :: ReadS [VulkanException]
$creadPrec :: ReadPrec VulkanException
readPrec :: ReadPrec VulkanException
$creadListPrec :: ReadPrec [VulkanException]
readListPrec :: ReadPrec [VulkanException]
Read, Int -> VulkanException -> ShowS
[VulkanException] -> ShowS
VulkanException -> String
(Int -> VulkanException -> ShowS)
-> (VulkanException -> String)
-> ([VulkanException] -> ShowS)
-> Show VulkanException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VulkanException -> ShowS
showsPrec :: Int -> VulkanException -> ShowS
$cshow :: VulkanException -> String
show :: VulkanException -> String
$cshowList :: [VulkanException] -> ShowS
showList :: [VulkanException] -> ShowS
Show)

instance Exception VulkanException where
  displayException :: VulkanException -> String
displayException (VulkanException Result
r) = Result -> String
forall a. Show a => a -> String
show Result
r String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
": " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Result -> String
resultString Result
r

-- | A human understandable message for each VkResult
resultString :: Result -> String
resultString :: Result -> String
resultString = \case
  Result
SUCCESS -> String
"Command completed successfully"
  Result
NOT_READY -> String
"A fence or query has not yet completed"
  Result
TIMEOUT -> String
"A wait operation has not completed in the specified time"
  Result
EVENT_SET -> String
"An event is signaled"
  Result
EVENT_RESET -> String
"An event is unsignaled"
  Result
INCOMPLETE -> String
"A return array was too small for the result"
  Result
ERROR_OUT_OF_HOST_MEMORY -> String
"A host memory allocation has failed"
  Result
ERROR_OUT_OF_DEVICE_MEMORY -> String
"A device memory allocation has failed"
  Result
ERROR_INITIALIZATION_FAILED -> String
"Initialization of an object has failed"
  Result
ERROR_DEVICE_LOST -> String
"The logical device has been lost. See &lt;&lt;devsandqueues-lost-device&gt;&gt;"
  Result
ERROR_MEMORY_MAP_FAILED -> String
"Mapping of a memory object has failed"
  Result
ERROR_LAYER_NOT_PRESENT -> String
"Layer specified does not exist"
  Result
ERROR_EXTENSION_NOT_PRESENT -> String
"Extension specified does not exist"
  Result
ERROR_FEATURE_NOT_PRESENT -> String
"Requested feature is not available on this device"
  Result
ERROR_INCOMPATIBLE_DRIVER -> String
"Unable to find a Vulkan driver"
  Result
ERROR_TOO_MANY_OBJECTS -> String
"Too many objects of the type have already been created"
  Result
ERROR_FORMAT_NOT_SUPPORTED -> String
"Requested format is not supported on this device"
  Result
ERROR_FRAGMENTED_POOL -> String
"A requested pool allocation has failed due to fragmentation of the pool's memory"
  Result
ERROR_UNKNOWN -> String
"An unknown error has occurred, due to an implementation or application bug"
  Result
r -> Result -> String
forall a. Show a => a -> String
show Result
r