@@ -16,11 +16,11 @@ export default function mandatoryTest_6_1_13(doc) {
1616 /** @type {any } */ fullProductName ,
1717 /** @type {number } */ fullProductNameIndex
1818 ) => {
19- checkProductIdentificationHelperPURL ( fullProductName , ( ) => {
19+ checkProductIdentificationHelperPURL ( fullProductName , ( errorMessage ) => {
2020 isValid = false
2121 errors . push ( {
2222 instancePath : `/product_tree/full_product_names/${ fullProductNameIndex } /product_identification_helper/purl` ,
23- message : `invalid purl` ,
23+ message : `invalid purl: ${ errorMessage } ` ,
2424 } )
2525 } )
2626 }
@@ -35,11 +35,11 @@ export default function mandatoryTest_6_1_13(doc) {
3535 ) => {
3636 checkProductIdentificationHelperPURL (
3737 relationship . full_product_name ,
38- ( ) => {
38+ ( errorMessage ) => {
3939 isValid = false
4040 errors . push ( {
4141 instancePath : `/product_tree/relationships/${ relationshipIndex } /full_product_name/product_identification_helper/purl` ,
42- message : `invalid purl` ,
42+ message : `invalid purl: ${ errorMessage } ` ,
4343 } )
4444 }
4545 )
@@ -48,15 +48,15 @@ export default function mandatoryTest_6_1_13(doc) {
4848 }
4949
5050 if ( doc . product_tree ) {
51- checkBranchesForInvalidPURLs ( doc . product_tree , ( { branchIndexes } ) => {
51+ checkBranchesForInvalidPURLs ( doc . product_tree , ( { branchIndexes, errorMessage } ) => {
5252 isValid = false
5353 const branchPathPart = branchIndexes . reduce (
5454 ( str , index ) => `${ str } /branches/${ index } ` ,
5555 '/product_tree'
5656 )
5757 errors . push ( {
5858 instancePath : `${ branchPathPart } /product/product_identification_helper/purl` ,
59- message : `invalid purl` ,
59+ message : `invalid purl: ${ errorMessage } ` ,
6060 } )
6161 } )
6262 }
@@ -67,7 +67,7 @@ export default function mandatoryTest_6_1_13(doc) {
6767/**
6868 *
6969 * @param {any } parent
70- * @param {(error: { branchIndexes: number[] }) => void } onError
70+ * @param {(error: { branchIndexes: number[], errorMessage: string }) => void } onError
7171 * @param {number[] } [branchIndexes]
7272 */
7373const checkBranchesForInvalidPURLs = ( parent , onError , branchIndexes = [ ] ) => {
@@ -76,9 +76,10 @@ const checkBranchesForInvalidPURLs = (parent, onError, branchIndexes = []) => {
7676 ( /** @type {any } */ branch , /** @type {number } */ branchIndex ) => {
7777 const currentBranchIndexes = branchIndexes . concat ( [ branchIndex ] )
7878
79- checkProductIdentificationHelperPURL ( branch . product , ( ) => {
79+ checkProductIdentificationHelperPURL ( branch . product , ( errorMessage ) => {
8080 onError ( {
8181 branchIndexes : currentBranchIndexes ,
82+ errorMessage,
8283 } )
8384 } )
8485 checkBranchesForInvalidPURLs ( branch , onError , currentBranchIndexes )
@@ -89,7 +90,7 @@ const checkBranchesForInvalidPURLs = (parent, onError, branchIndexes = []) => {
8990
9091/**
9192 * @param {any } productALike
92- * @param {() => void } onError
93+ * @param {(errorMessage: string ) => void } onError
9394 * @returns
9495 */
9596const checkProductIdentificationHelperPURL = ( productALike , onError ) => {
@@ -98,6 +99,7 @@ const checkProductIdentificationHelperPURL = (productALike, onError) => {
9899 try {
99100 PackageURL . fromString ( productALike ?. product_identification_helper ?. purl )
100101 } catch ( e ) {
101- onError ( )
102+ const errorObject = /** @type {{message: string} } */ ( e )
103+ onError ( errorObject ?. message ?? "Unknown purl error" )
102104 }
103105}
0 commit comments