File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 33import { writeFileSync } from 'fs' ;
44import { join } from 'path' ;
55
6- import fetch from 'cross-fetch' ;
76import * as z from 'zod' ;
87
98const sourceUrl = ( branch = 'master' ) =>
109 `https://github.com/postgres/postgres/raw/${ branch } /src/backend/utils/errcodes.txt` ;
1110
12- const getSourceText = ( ) : Promise < string [ ] > =>
13- fetch ( sourceUrl ( ) )
14- . then ( ( response ) => response . text ( ) )
15- . then ( ( text ) => text . split ( '\n' ) ) ;
11+ const getSourceText = async ( ) : Promise < string [ ] > => {
12+ const response = await fetch ( sourceUrl ( ) ) ;
13+
14+ if ( ! response . ok ) {
15+ throw new Error ( `Error fetching errcodes.txt: ${ response . status } ` ) ;
16+ }
17+
18+ const text = await response . text ( ) ;
19+ return text . split ( '\n' ) ;
20+ } ;
1621
1722const stripCommentsAndEmptyLines = ( lines : string [ ] ) =>
1823 lines . filter ( ( line ) => line !== '' && line . charAt ( 0 ) !== '#' ) ;
You can’t perform that action at this time.
0 commit comments