Skip to content

Commit cb9f7b5

Browse files
committed
Remove error handling section
1 parent 64d10ba commit cb9f7b5

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

docs/cookbook.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -469,52 +469,3 @@ const prices = ["19.99", "5.50", "105.00", "0.99", "50.00"];
469469
console.log(findMinMax(prices));
470470
// => { min: "0.99", max: "105.00" }
471471
```
472-
473-
## Error Handling
474-
475-
### Safe parsing of user input
476-
477-
Handle potentially invalid decimal input:
478-
479-
```javascript
480-
function parseUserDecimal(input) {
481-
try {
482-
const decimal = new Decimal(input);
483-
484-
// Check for special values
485-
if (decimal.isNaN()) {
486-
return { success: false, error: "Invalid number" };
487-
}
488-
if (!decimal.isFinite()) {
489-
return { success: false, error: "Number must be finite" };
490-
}
491-
492-
return { success: true, value: decimal };
493-
} catch (error) {
494-
return { success: false, error: "Invalid decimal format" };
495-
}
496-
}
497-
```
498-
499-
### Division by zero handling
500-
501-
Safely handle division operations:
502-
503-
```javascript
504-
function safeDivide(dividend, divisor) {
505-
const a = new Decimal(dividend);
506-
const b = new Decimal(divisor);
507-
508-
if (b.equals(new Decimal(0))) {
509-
return { success: false, error: "Division by zero" };
510-
}
511-
512-
const result = a.divide(b);
513-
514-
if (!result.isFinite()) {
515-
return { success: false, error: "Result is infinite" };
516-
}
517-
518-
return { success: true, value: result };
519-
}
520-
```

0 commit comments

Comments
 (0)