Skip to content

jazz-soft/xx-err

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xx-err

npm npm build Coverage

XML errors:

  • FOAP0001: Wrong number of arguments.
  • FOAR0001: Division by zero.
  • FOAR0002: Numeric operation overflow/underflow.
  • FOAY0001: Array index out of bounds.
  • FOAY0002: Negative array length.
  • FOCA0001: Input value too large for decimal.
  • FOCA0002: Invalid lexical value.
  • FOCA0003: Input value too large for integer.
  • FOCA0005: NaN supplied as float/double value.
  • FOCA0006: String to be cast to decimal has too many digits of precision.
  • FOCH0001: Codepoint not valid.
  • FOCH0002: Unsupported collation.
  • FOCH0003: Unsupported normalization form.
  • FOCH0004: Collation does not support collation units.
  • FODC0001: No context document.
  • FODC0002: Error retrieving resource.
  • FODC0003: Function not defined as deterministic.
  • FODC0004: Invalid collection URI.
  • FODC0005: Invalid argument to fn:doc or fn:doc-available.
  • FODC0006: String passed to fn:parse-xml is not a well-formed XML document.
  • FODC0010: The processor does not support serialization.
  • FODF1280: Invalid decimal format name.
  • FODF1310: Invalid decimal format picture string.
  • FODT0001: Overflow/underflow in date/time operation.
  • FODT0002: Overflow/underflow in duration operation.
  • FODT0003: Invalid timezone value.
  • FOER0000: Unidentified error.
  • FOFD1340: Invalid date/time formatting parameters.
  • FOFD1350: Invalid date/time formatting component.
  • FOJS0001: JSON syntax error.
  • FOJS0003: JSON duplicate keys.
  • FOJS0004: JSON: not schema-aware.
  • FOJS0005: Invalid options.
  • FOJS0006: Invalid XML representation of JSON.
  • FOJS0007: Bad JSON escape sequence.
  • FONS0004: No namespace found for prefix.
  • FONS0005: Base-uri not defined in the static context.
  • FOQM0001: Module URI is a zero-length string.
  • FOQM0002: Module URI not found.
  • FOQM0003: Static error in dynamically-loaded XQuery module.
  • FOQM0005: Parameter for dynamically-loaded XQuery module has incorrect type.
  • FOQM0006: No suitable XQuery processor available.
  • FORG0001: Invalid value for cast/constructor.
  • FORG0002: Invalid argument to fn:resolve-uri().
  • FORG0003: fn:zero-or-one called with a sequence containing more than one item.
  • FORG0004: fn:one-or-more called with a sequence containing no items.
  • FORG0005: fn:exactly-one called with a sequence containing zero or more than one item.
  • FORG0006: Invalid argument type.
  • FORG0008: The two arguments to fn:dateTime have inconsistent timezones.
  • FORG0009: Error in resolving a relative URI against a base URI in fn:resolve-uri.
  • FORG0010: Invalid date/time.
  • FORX0001: Invalid regular expression flags.
  • FORX0002: Invalid regular expression.
  • FORX0003: Regular expression matches zero-length string.
  • FORX0004: Invalid replacement string.
  • FOTY0012: Argument to fn:data() contains a node that does not have a typed value.
  • FOTY0013: The argument to fn:data() contains a function item.
  • FOTY0014: The argument to fn:string() is a function item.
  • FOTY0015: An argument to fn:deep-equal() contains a function item.
  • FOUT1170: Invalid $href argument to fn:unparsed-text() (etc.)
  • FOUT1190: Cannot decode resource retrieved by fn:unparsed-text() (etc.)
  • FOUT1200: Cannot infer encoding of resource retrieved by fn:unparsed-text() (etc.)
  • FOXT0001: No suitable XSLT processor available.
  • FOXT0002: Invalid parameters to XSLT transformation.
  • FOXT0003: XSLT transformation failed.
  • FOXT0004: XSLT transformation has been disabled.
  • FOXT0006: XSLT output contains non-accepted characters.
  • XPST0003: Syntax error.

Usage:

npm install xx-err --save

const err = require('xx-err');

// ...

if (/*something wrong*/) err.XPST0003('Something went wrong...');

// - this throws the following Error:
// err:XPST0003, Syntax error. Something went wrong...
// see https://www.w3.org/TR/xpath-31/#ERRXPST0003

Arguments:

err.XPST0003(); err.XPST0003(str); err.XPST0003(obj); err.XPST0003(str, obj);

  • str - a string to be included in the error's message.
  • obj - additional data to attach to the error object.

e.g:

try {
  err.XPST0003('Oops!', { row: 2, col: 5 });
}
catch (e) {
  console.log(e.code); // XPST0003
  console.log(e.message);
  // err:XPST0003, Syntax error. Oops!
  // see https://www.w3.org/TR/xpath-31/#ERRXPST0003
  console.log(e.row);  // 2
  console.log(e.col);  // 5
}