v1.2.0 Throw Error objects

This commit is contained in:
Michael Mclaughlin 2013-09-19 12:15:54 +01:00
parent 6771e89996
commit aeb5646957
5 changed files with 36 additions and 33 deletions

View File

@ -211,6 +211,9 @@ See LICENCE.
## Change Log
####1.2.0
* 19/9/2013 Throw Error objects for stack.
####1.1.1
* 22/8/2013 Show original value in constructor error message.
@ -222,5 +225,3 @@ See LICENCE.
####1.0.0
* 8/11/2012 Initial release
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/50b85fd919b406ef9312551092a95fb7 "githalytics.com")](http://githalytics.com/MikeMcl/bignumber.js)

View File

@ -1,9 +1,9 @@
/* bignumber.js v1.1.1 https://github.com/MikeMcl/bignumber.js/LICENCE */
/* bignumber.js v1.2.0 https://github.com/MikeMcl/bignumber.js/LICENCE */
;(function ( global ) {
'use strict';
/*
bignumber.js v1.1.1
bignumber.js v1.2.0
A JavaScript library for arbitrary-precision arithmetic.
https://github.com/MikeMcl/bignumber.js
Copyright (c) 2012 Michael Mclaughlin <M8ch88l@gmail.com>
@ -409,32 +409,33 @@
// Assemble error messages. Throw BigNumber Errors.
function ifExceptionsThrow( arg, i, j, isArray, isRange, isErrors) {
if ( ERRORS ) {
var method = ['new BigNumber', 'cmp', 'div', 'eq', 'gt', 'gte', 'lt',
var error,
method = ['new BigNumber', 'cmp', 'div', 'eq', 'gt', 'gte', 'lt',
'lte', 'minus', 'mod', 'plus', 'times', 'toFr'
][ id ? id < 0 ? -id : id : 1 / id < 0 ? 1 : 0 ] + '()',
error = outOfRange ? ' out of range' : ' not a' +
message = outOfRange ? ' out of range' : ' not a' +
( isRange ? ' non-zero' : 'n' ) + ' integer';
error = ( [
message = ( [
method + ' number type has more than 15 significant digits',
method + ' not a base ' + j + ' number',
method + ' base' + error,
method + ' base' + message,
method + ' not a number' ][i] ||
j + '() ' + i + ( isErrors
? ' not a boolean or binary digit'
: error + ( isArray
: message + ( isArray
? ' or not [' + ( outOfRange
? ' negative, positive'
: ' integer, integer' ) + ' ]'
: '' ) ) ) + ': ' + arg;
outOfRange = id = 0;
throw {
name : 'BigNumber Error',
message : error,
toString : function () {return this.name + ': ' + this.message}
}
error = new Error(message);
error['name'] = 'BigNumber Error';
throw error
}
}

2
bignumber.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1465,9 +1465,10 @@ y.s // -1</pre>
<h4 id='Errors'>Errors</h4>
<p>
The table below shows the BigNumber Errors that may be thrown if
<code>ERRORS</code> is <code>true</code>, and what happens if
<code>ERRORS</code> is <code>false</code>.
The errors that are thrown are generic <code>Error</code> objects with
<code>name</code> <i>BigNumber Error</i>. The table below shows the errors
that may be thrown if <code>ERRORS</code> is <code>true</code>, and the
action taken if <code>ERRORS</code> is <code>false</code>.
</p>
<table class='error-table'>
<tr>
@ -1637,18 +1638,18 @@ y.s // -1</pre>
<sup>*</sup>No error is thrown if the value is <code>NaN</code> or 'NaN'
</p>
<p>
The message of a BigNumber Error will also contain the name of the
The message of a <i>BigNumber Error</i> will also contain the name of the
method from which the error originated.
</p>
<p>
To determine if an exception is a BigNumber Error:
To determine if an exception is a <i>BigNumber Error</i>:
</p>
<pre>
try {
// do something with BigNumbers
// ...
} catch (e) {
if (e.name == 'BigNumber Error') {
// do something
if ( e instanceof Error && e.name == 'BigNumber Error' ) {
// ...
}
}</pre>

View File

@ -1,7 +1,7 @@
{
"name": "bignumber.js",
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
"version": "1.1.1",
"version": "1.2.0",
"keywords": [
"arbitrary",
"precision",