jsbeans

jsbeans  1.0.0

jsbeans > jsbeans > Error.js (source view)
Search:
 
Filters
/*!
 * Copyright (c) 2009 Francesco Mele jsbeans@francescomele.com
 *
 * This Software is licenced under the LGPL Licence (GNU Lesser General 
 * Public License).
 * In addition to the LGPL Licence the Software is subject to the 
 * following conditions:
 * 
 * 	i	every modification must be public and comunicated to the Author
 * 	ii	every "jsbean" added to this library must be self consistent 
 * 		except for the dependence from jsbeans-x.x.x.js
 * 	iii	copyright notice and this permission notice shall be included 
 * 		in all copies or substantial portions of the Software
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */
/**
 * Utility for full stack trace of errors
 * @namespace jsbeans
 * @class Error
 * @constructor
 * @param error {Object} any error object supported by javascript (e.g. <code>throw "Any message";</code> rather than <code>throw new Error("A message");</code>)
 * */
jsbeans.Error = function(error) {
	this.stackTrace = function() {
		return error.message;
	};
	// Error is not enumerable
	this.getProperties = function() {
		var res = {
			message: error.message
		};
		if ('name' in error) {
			res.name = error.name;
		}
		if ('description' in error) {
			res.description = error.description;
		}
		if ('stack' in error) {
			res.stack = error.stack;
		}
		if ('number' in error) {
			res.number = error.number;
		}
		if ('lineNumber' in error) {
			res.lineNumber = error.lineNumber;
		}
		if ('fileName' in error) {
			res.fileName = error.fileName;
		}
		return res;
	}
};

Copyright © 2016 Francesco Mele. All rights reserved.