PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Exceptions

Exceptions

Exceptions are a feature.

In general, an exception breaks the normal flow of execution and executes a pre-registered exception handler.


Languages with Exceptions include Java, JavaScript, C++, PHP, C#, Ruby, Swift, Scala, Kotlin, PowerShell, Elixir, Dart, Solidity, CoffeeScript, Groovy, ABAP, REBOL, X10, Apex, Boron, Sophia

Example from JavaScript:
try { undefinedFn() } catch (err) { console.log(err) }
Example from Ruby:
def hello puts "Hello, World!" # start an exception handler begin raise "This is an exception" rescue => e puts "Exception caught: #{e}" end end hello
Example from Elixir:
raise "oops, something went wrong"
Example from REBOL:
catch [throw 22 print "You'll never see this."] try/except [read %does_not_exist] [print "File not found"]
Example from Boron:
catch [throw 22 print "You'll never see this."] if error? try [read %does_not_exist] [print "File not found"]
directives-feature.html 路 exceptions-feature.html 路 floats-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 33 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub feedback@pldb.com