Dart: Exceptions

# Built-in Dart exceptions include
DeferredLoadExceptionThrown when a deferred library fails to load.
FormatExceptionThe exception is thrown when a string or some other data does not have an expected format and cannot be parsed or processed.
IntegerDivisionByZeroExceptionThrown when a number is divided by zero.
IOExceptionBase class for all Inupt- Output related exceptions.
IsolateSpawnExceptionThrown when an isolate cannot be created.
TimeoutThrown when a scheduled timeout happens while waiting for an async result.
# The try/ on/ catch Blocks
try { 
   // code that might throw an exception 
}  
on Exception1 { 
   // code for handling exception 
}  
catch Exception2 { 
   // code for handling exception 
} 
# The Finally Block
try { 
   // code that might throw an exception 
}  
on Exception1 { 
   // exception handling code 
}  
catch Exception2 { 
   //  exception handling 
}  
finally { 
   // code that should always execute; irrespective of the exception 
}
# Throwing an Exception
throw new Exception_name()

Leave a Reply

Your email address will not be published. Required fields are marked *