Java Script Error Codes
Contents |
References & Guides Learning web development Tutorials References Developer Guides Accessibility Game development ...more docs Mozilla Docs Add-ons Firefox Developer ToolsFeedback javascript error object Get Firefox help Get web development help Join the MDN community Report define mistakenly a content problem Report a bug Search Search Languages Català (ca) Deutsch (de) Español (es) Français define inaccuracy (fr) Bahasa Indonesia (id) 日本語 (ja) 한국어 (ko) Polski (pl) Português (do Brasil) (pt-BR) Русский (ru) 中文 (简体) (zh-CN) 正體中文 (繁體) (zh-TW) Add a translation Edit Advanced Advanced History Print
Define Miscalculation
this article MDN Web technology For developers JavaScript JavaScript reference Standard built-in objects Error Your Search Results ariyankhan josephmcasey AlexanderFradiani fscholz mondwan SphinxKnight janosch-x davidchase Mingun shawnacscott Sheppy ethertank Nickolay evilpie trevorh teoli davidbourguignon secoif DomenicDenicola dgchurchill timemachine3030 Sevenspade Potappo Sephr Brettz9 Mgjbot Allanbonadio Ptak82 JustinLudwig Error In This Article SyntaxParametersDescriptionError typesPropertiesMethodsError instancesPropertiesStandard propertiesVendor-specific extensionsMicrosoftMozillaMethodsExamplesThrowing a generic errorHandling javascript throw exception a specific errorCustom Error TypesSpecificationsBrowser compatibilitySee also The Error constructor creates an error object. Instances of Error objects are thrown when runtime errors occur. The Error object can also be used as a base object for user-defined exceptions. See below for standard built-in error types. Syntax new Error([message[, fileName[, lineNumber]]]) Parameters message Optional. Human-readable description of the error. fileName Optional. The value for the fileName property on the created Error object. Defaults to the name of the file containing the code that called the Error() constructor. lineNumber Optional. The value for the lineNumber property on the created Error object. Defaults to the line number containing the Error() constructor invocation. Description Runtime errors result in new Error objects being created and thrown. This page documents the use of the Error object itself and its use as a constructor function. For a list of properties and methods inherited by Error instances, see Error.prototype. Error types Besides the generic Error constructor, there are six other core error constructors in JavaScript. For client-side exceptions, see Exception Handling Statement
as expected is a good start. Making your programs behave properly when encountering unexpected conditions is where it really eror gets challenging. ¶ The problematic situations that a program can encounter fall
What Is Error
into two categories: Programmer mistakes and genuine problems. If someone forgets to pass a required argument to
Define Misconception
a function, that is an example of the first kind of problem. On the other hand, if a program asks the user to enter a name and it gets https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error back an empty string, that is something the programmer can not prevent. ¶ In general, one deals with programmer errors by finding and fixing them, and with genuine errors by having the code check for them and perform some suitable action to remedy them (for example, asking for the name again), or at least fail in a http://eloquentjavascript.net/1st_edition/chapter5.html well-defined and clean way. ¶ It is important to decide into which of these categories a certain problem falls. For example, consider our old power function:function power(base, exponent) { var result = 1; for (var count = 0; count < exponent; count++) result *= base; return result; } ¶ When some geek tries to call power("Rabbit", 4), that is quite obviously a programmer error, but how about power(9, 0.5)? The function can not handle fractional exponents, but, mathematically speaking, raising a number to the halfth power is perfectly reasonable (Math.pow can handle it). In situations where it is not entirely clear what kind of input a function accepts, it is often a good idea to explicitly state the kind of arguments that are acceptable in a comment. ¶ If a function encounters a problem that it can not solve itself, what should it do? In chapter 4 we wrote the function between:function between(string, start, end) { var startAt = string.indexOf(start) + start.length; var endAt = string.indexOf(end, startAt); return string.slice(startAt, endAt);
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs https://msdn.microsoft.com/en-us/library/hc53e755(v=vs.94).aspx and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. JavaScript Reference JavaScript Objects Error Object Error Object number Property (Error) number Property (Error) number Property (Error) constructor Property (Error) prototype Property (Error) description Property (Error) message Property (Error) name Property (Error) number Property (Error) stack Property script error (Error) stackTraceLimit Property (Error) toString Method (Error) valueOf Method (Error) TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. number Property (Error) (JavaScript) Returns or sets the numeric value associated with a specific error. The Error object's default property is number.Syntax java script error Copy object .number [= errorNumber] ParametersObjectAny instance of the Error object.errorNumberAn integer representing an error.RemarksAn error number is a 32-bit value. The upper 16-bit word is the facility code, and the lower word is the error code. To determine the error code, use the & (bitwise And) operator to combine the number property with the hexadecimal number 0xFFFF.ExampleThe following example causes an exception to be thrown and displays the error code that is derived from the error number. JavaScript Copy try { // Cause an error. var x = y; } catch(e) { document.write ("Error Code: "); document.write (e.number & 0xFFFF) document.write ("
"); document.write ("Facility Code: ") document.write(e.number>>16 & 0x1FFF) document.write ("
"); document.write ("Error Message: ") document.write (e.message) } ExampleThe output of this code is as follows. JavaScript Copy Error Code: 5009 Facility Code: 10 Error Message: 'y' is undefined RequirementsSupported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (W