UNPKG

@digicatapult/dtdl-parser

Version:

JS tool to parse DTDL defined Ontologies

15 lines (14 loc) 715 B
let { error: o } = console; export const isResolutionException = (o)=>o instanceof Error && 'Resolution' === JSON.parse(o.message).ExceptionKind; export const isModelingException = (o)=>'object' == typeof o && null !== o && 'ExceptionKind' in o && ('Parsing' === o.ExceptionKind || 'Resolution' === o.ExceptionKind); export const errorHandler = (e)=>{ if (!(e instanceof Error)) throw o('Non-Error thrown:', e), e; try { let o = JSON.parse(e.message); if ('Parsing' === o.ExceptionKind || 'Resolution' === o.ExceptionKind) return o; } catch (e) { o('Failed to parse error message:', e); } throw o('Unknown error from parser:', e), e; }; //# sourceMappingURL=error.js.map