(modelRef, modelPaths)
| 36 | } |
| 37 | |
| 38 | function requireUsingModelPaths(modelRef, modelPaths) { |
| 39 | let firstError = null; |
| 40 | |
| 41 | for (const modelPath of modelPaths) { |
| 42 | try { |
| 43 | return requireModel(path.join(modelPath, modelRef)); |
| 44 | } catch (err) { |
| 45 | if (firstError === null) { |
| 46 | firstError = err; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | if (firstError) { |
| 52 | throw firstError; |
| 53 | } else { |
| 54 | throw new ResolveError(`could not resolve ${modelRef} using modelPaths`); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | function requireModel(modelPath) { |
| 59 | /** |
no test coverage detected