File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 1
- import { WorkBook } from '~/common/xlsx.util' ;
1
+ import { InputException , NotFoundException } from '~/common' ;
2
+ import { type Sheet , WorkBook } from '~/common/xlsx.util' ;
2
3
import { type Downloadable , type FileVersion } from '../file/dto' ;
3
4
import { PlanningSheet } from './planning-sheet' ;
4
5
import { ProgressSheet } from './progress-sheet' ;
@@ -28,10 +29,26 @@ export class Pnp {
28
29
}
29
30
30
31
get planning ( ) {
31
- return this . workbook . sheet < PlanningSheet > ( 'Planning' ) ;
32
+ return this . sheet < PlanningSheet > ( 'Planning' ) ;
32
33
}
33
34
34
35
get progress ( ) {
35
- return this . workbook . sheet < ProgressSheet > ( 'Progress' ) ;
36
+ return this . sheet < ProgressSheet > ( 'Progress' ) ;
37
+ }
38
+
39
+ protected sheet < TSheet extends Sheet > ( name : string ) : TSheet {
40
+ try {
41
+ return this . workbook . sheet ( name ) ;
42
+ } catch ( e ) {
43
+ if ( e instanceof NotFoundException && this . fileName ?. match ( / \b U B T \b / ) ) {
44
+ throw new NotPnPFile (
45
+ `It appears you are uploading a _budget_ excel file, not a _PnP_ file.` ,
46
+ e ,
47
+ ) ;
48
+ }
49
+ throw e ;
50
+ }
36
51
}
37
52
}
53
+
54
+ export class NotPnPFile extends InputException { }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { DateTime } from 'luxon';
7
7
import { DateInterval , type ID } from '~/common' ;
8
8
import { ILogger , Logger , ResourceLoader } from '~/core' ;
9
9
import { type Downloadable , type FileVersion } from '../file/dto' ;
10
+ import { NotPnPFile } from '../pnp' ;
10
11
import {
11
12
type PnpExtractionResult ,
12
13
PnpProblemType ,
@@ -67,10 +68,12 @@ export class PnpProductSyncService {
67
68
result ,
68
69
) ;
69
70
} catch ( e ) {
70
- this . logger . error ( e . message , {
71
- id : pnp . id ,
72
- exception : e ,
73
- } ) ;
71
+ if ( ! ( e instanceof NotPnPFile ) ) {
72
+ this . logger . error ( e . message , {
73
+ id : pnp . id ,
74
+ exception : e ,
75
+ } ) ;
76
+ }
74
77
return [ ] ;
75
78
}
76
79
if ( productRows . length === 0 ) {
You can’t perform that action at this time.
0 commit comments