You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
639 B
21 lines
639 B
11 months ago
|
|
||
|
Cloning: the default choice is a deep copy (although be aware of memory usage).
|
||
|
|
||
|
Common options for handling errors:
|
||
|
* Close program
|
||
|
* Throw exception
|
||
|
* Use a reasonable or neutral value
|
||
|
* Log the error
|
||
|
* Print the error
|
||
|
* Do nothing
|
||
|
[* Use an assert if you want an error thrown, but only during development]
|
||
|
|
||
|
Example of an assert (in Java, assertions are enabled by running it with the -ea flag)
|
||
|
lat = ... //calculation happens here
|
||
|
|
||
|
//We want an error thrown if it's out of bounds, but only during development
|
||
|
assert (lat >= -90 && lat <= 90) : "Latitude out of bounds";
|
||
|
|
||
|
if (lat > 90) lat = 90;
|
||
|
if (lat < -90) lat = -90;
|
||
|
|