1
1
// REF: https://chat.openai.com/c/828fa9d6-981d-404a-8ef8-46e8140111ba
2
2
//
3
- import type { Definitions } from "internet-object" ;
4
- import { parse } from "internet-object"
5
- import { parseDefinitions } from 'internet-object' ;
6
- import { InternetObjectError } from 'internet-object' ;
7
- import { InternetObjectSyntaxError } from 'internet-object' ;
8
- import { InternetObjectValidationError } from 'internet-object' ;
3
+ import type { IODefinitions } from "internet-object" ;
4
+ import { parse } from "internet-object"
5
+ import { parseDefinitions } from 'internet-object' ;
6
+ import { IOError } from 'internet-object' ;
7
+ import { IOSyntaxError } from 'internet-object' ;
8
+ import { IOValidationError } from 'internet-object' ;
9
9
10
10
11
11
/**
@@ -25,7 +25,7 @@ export interface ErrorMarker {
25
25
*/
26
26
export interface ParsingResult {
27
27
errorMessage : string | null ;
28
- defs : Definitions | null ;
28
+ defs : IODefinitions | null ;
29
29
output : any | null ;
30
30
defsMarkers : ErrorMarker [ ] ;
31
31
docMarkers : ErrorMarker [ ] ;
@@ -52,7 +52,7 @@ function tryParse<T>(input: string, fn: (input: string, defs?: any) => T, isDefs
52
52
const result = fn ( input , null ) ;
53
53
return {
54
54
errorMessage : null ,
55
- defs : isDefs ? result as Definitions : null ,
55
+ defs : isDefs ? result as IODefinitions : null ,
56
56
output : isDefs ? null : ( result as any ) . toJSON ( ) ,
57
57
defsMarkers : [ ] ,
58
58
docMarkers : [ ] ,
@@ -74,22 +74,22 @@ function tryParse<T>(input: string, fn: (input: string, defs?: any) => T, isDefs
74
74
75
75
76
76
77
- function parseDoc ( doc : string , defs : Definitions | null = null ) : ParsingResult {
77
+ function parseDoc ( doc : string , defs : IODefinitions | null = null ) : ParsingResult {
78
78
return tryParse ( doc , ( d ) => parse ( d , defs ) ) ;
79
79
}
80
80
81
81
82
82
83
83
function getErrorMessage ( e : any ) : string {
84
- if ( e instanceof InternetObjectSyntaxError ) return 'SYNTAX_ERROR: ' + ( e ?. message || String ( e ) ) ;
85
- if ( e instanceof InternetObjectValidationError ) return 'VALIDATION_ERROR: ' + ( e ?. message || String ( e ) ) ;
84
+ if ( e instanceof IOSyntaxError ) return 'SYNTAX_ERROR: ' + ( e ?. message || String ( e ) ) ;
85
+ if ( e instanceof IOValidationError ) return 'VALIDATION_ERROR: ' + ( e ?. message || String ( e ) ) ;
86
86
return 'ERROR: ' + ( e ?. message || String ( e ) ) ;
87
87
}
88
88
89
89
90
90
91
91
function getErrorMarkers ( e : any ) : ErrorMarker [ ] {
92
- if ( ! ( e instanceof InternetObjectError ) ) return [ ] ;
92
+ if ( ! ( e instanceof IOError ) ) return [ ] ;
93
93
const startPos : any = e . positionRange ?. getStartPos ( ) ;
94
94
const endPos : any = e . positionRange ?. getEndPos ( ) ;
95
95
if ( ! startPos && ! endPos ) return [ ] ;
0 commit comments