@graphty/graphty-element / extend / ImportError
Class: ImportError ​
Defined in: graph-io/dist/src/types.d.ts:503
What a load function throws when the input cannot be read: the URL failed, the format was not recognized, the file could not be parsed, or there were more errors than errorLimit. It is a GraphFormatError with code "E_IMPORT"; issue says what stopped the import and report holds everything recorded until then.
Extends ​
GraphFormatError
Constructors ​
Constructor ​
new ImportError(
message,report,details?):ImportError
Defined in: graph-io/dist/src/types.d.ts:536
Create an ImportError.
Parameters ​
message ​
string
a plain-ASCII human-readable message
report ​
the partial report
details? ​
Readonly<Record<string, unknown>>
optional machine-readable context; its code names the issue that stopped the import
Returns ​
ImportError
Overrides ​
GraphFormatError.constructor
Properties ​
code ​
readonlycode:GraphFormatErrorCode
Defined in: graph-format/dist/src/errors.d.ts:68
The stable error code (design section 11.2).
Inherited from ​
GraphFormatError.code
details ​
readonlydetails:Readonly<Record<string,unknown>>
Defined in: graph-format/dist/src/errors.d.ts:70
Machine-readable context for the failure; an empty frozen object when none was supplied.
Inherited from ​
GraphFormatError.details
issue ​
readonlyissue:ImportIssue|null
Defined in: graph-io/dist/src/types.d.ts:529
The issue that stopped the import: its code ("E_FETCH", "E_UNKNOWN_FORMAT", "E_CSV_UNCLOSED_QUOTE", ...), message, line and element. This is the value to branch on; code is always "E_IMPORT". Null only for an ImportError constructed by hand without a matching issue.
Example ​
if (err instanceof ImportError) {
switch (err.issue?.code) {
case "E_FETCH":
console.error(`download failed with status ${String(err.details.status)}`);
break;
case "E_UNKNOWN_FORMAT":
console.error("not a graph file this library can read; pass `format`");
break;
default:
console.error(err.message);
}
}report ​
readonlyreport:ImporterReport
Defined in: graph-io/dist/src/types.d.ts:508
Everything recorded up to the point the import stopped. It is not an enumerable property, so an uncaught ImportError prints its message and issue, not every issue of the report.