or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-execution.mdexception-handling.mdindex.mdlifecycle-management.mdplugin-system.mdproject-management.mdrepository-system.md

exception-handling.mddocs/

0

# Exception Handling

1

2

Maven Core provides a comprehensive exception hierarchy for handling errors across all build operations. Understanding these exceptions enables proper error handling and recovery strategies in Maven-based applications and plugins.

3

4

## Core Maven Exceptions

5

6

### MavenExecutionException

7

8

Base exception for Maven execution failures.

9

10

```java { .api }

11

public class MavenExecutionException extends Exception {

12

/**

13

* Create exception with message and cause.

14

*

15

* @param message error message

16

* @param cause underlying cause

17

*/

18

public MavenExecutionException(String message, Throwable cause);

19

20

/**

21

* Create exception with message only.

22

*

23

* @param message error message

24

*/

25

public MavenExecutionException(String message);

26

27

/**

28

* Create exception with cause only.

29

*

30

* @param cause underlying cause

31

*/

32

public MavenExecutionException(Throwable cause);

33

}

34

```

35

36

### BuildFailureException

37

38

Exception indicating build failure with project context.

39

40

```java { .api }

41

public class BuildFailureException extends Exception {

42

/**

43

* Create build failure exception.

44

*

45

* @param message failure message

46

* @param cause underlying cause

47

*/

48

public BuildFailureException(String message, Throwable cause);

49

50

/**

51

* Create build failure exception with message.

52

*

53

* @param message failure message

54

*/

55

public BuildFailureException(String message);

56

57

/**

58

* Get the project where build failed (if available).

59

*

60

* @return Maven project or null

61

*/

62

public MavenProject getProject();

63

64

/**

65

* Get build phase where failure occurred.

66

*

67

* @return lifecycle phase

68

*/

69

public String getPhase();

70

}

71

```

72

73

### InternalErrorException

74

75

Exception for Maven internal errors and unexpected conditions.

76

77

```java { .api }

78

public class InternalErrorException extends Exception {

79

/**

80

* Create internal error exception.

81

*

82

* @param message error message

83

* @param cause underlying cause

84

*/

85

public InternalErrorException(String message, Throwable cause);

86

87

/**

88

* Create internal error exception with message.

89

*

90

* @param message error message

91

*/

92

public InternalErrorException(String message);

93

}

94

```

95

96

**Core Exception Handling Example:**

97

```java

98

import org.apache.maven.MavenExecutionException;

99

import org.apache.maven.BuildFailureException;

100

import org.apache.maven.InternalErrorException;

101

102

public void handleMavenExecution(Maven maven, MavenExecutionRequest request) {

103

try {

104

MavenExecutionResult result = maven.execute(request);

105

106

if (result.hasExceptions()) {

107

handleExecutionExceptions(result.getExceptions());

108

} else {

109

System.out.println("Build completed successfully");

110

}

111

112

} catch (MavenExecutionException e) {

113

System.err.println("Maven execution failed: " + e.getMessage());

114

handleMavenExecutionException(e);

115

} catch (InternalErrorException e) {

116

System.err.println("Maven internal error: " + e.getMessage());

117

e.printStackTrace();

118

// Log for debugging, may indicate Maven bug

119

}

120

}

121

122

private void handleExecutionExceptions(List<Throwable> exceptions) {

123

for (Throwable exception : exceptions) {

124

if (exception instanceof BuildFailureException) {

125

BuildFailureException buildFailure = (BuildFailureException) exception;

126

System.err.println("Build failed in project: " +

127

(buildFailure.getProject() != null ? buildFailure.getProject().getName() : "unknown"));

128

System.err.println("Phase: " + buildFailure.getPhase());

129

} else {

130

System.err.println("Build exception: " + exception.getMessage());

131

}

132

133

if (exception.getCause() != null) {

134

System.err.println("Caused by: " + exception.getCause().getMessage());

135

}

136

}

137

}

138

```

139

140

## Project Exceptions

141

142

### ProjectBuildingException

143

144

Exception thrown when project building fails.

145

146

```java { .api }

147

public class ProjectBuildingException extends Exception {

148

/**

149

* Create project building exception.

150

*

151

* @param projectId project identifier

152

* @param message error message

153

* @param pomFile POM file that failed to build

154

*/

155

public ProjectBuildingException(String projectId, String message, File pomFile);

156

157

/**

158

* Create project building exception with cause.

159

*

160

* @param projectId project identifier

161

* @param message error message

162

* @param pomFile POM file that failed to build

163

* @param cause underlying cause

164

*/

165

public ProjectBuildingException(String projectId, String message, File pomFile, Throwable cause);

166

167

/**

168

* Create exception for multiple project building results.

169

*

170

* @param projectId project identifier

171

* @param message error message

172

* @param results list of project building results with problems

173

*/

174

public ProjectBuildingException(String projectId, String message, List<ProjectBuildingResult> results);

175

176

/**

177

* Get project identifier.

178

*

179

* @return project ID

180

*/

181

public String getProjectId();

182

183

/**

184

* Get POM file that caused the failure.

185

*

186

* @return POM file

187

*/

188

public File getPomFile();

189

190

/**

191

* Get project building results (for batch operations).

192

*

193

* @return list of building results

194

*/

195

public List<ProjectBuildingResult> getResults();

196

}

197

```

198

199

### ProjectCycleException

200

201

Exception thrown when circular dependencies are detected between projects.

202

203

```java { .api }

204

import org.codehaus.plexus.util.dag.CycleDetectedException;

205

206

public class ProjectCycleException extends BuildFailureException {

207

/**

208

* Create project cycle exception.

209

*

210

* @param message error message describing the cycle

211

*/

212

public ProjectCycleException(String message);

213

214

/**

215

* Create project cycle exception with cause.

216

*

217

* @param message error message describing the cycle

218

* @param cause underlying cycle detection exception

219

*/

220

public ProjectCycleException(String message, CycleDetectedException cause);

221

}

222

```

223

224

### DependencyResolutionException

225

226

Exception for dependency resolution failures.

227

228

```java { .api }

229

public class DependencyResolutionException extends Exception {

230

/**

231

* Create dependency resolution exception.

232

*

233

* @param result dependency resolution result with problems

234

* @param message error message

235

* @param cause underlying cause

236

*/

237

public DependencyResolutionException(DependencyResolutionResult result, String message, Throwable cause);

238

239

/**

240

* Get dependency resolution result.

241

*

242

* @return resolution result containing resolved and unresolved dependencies

243

*/

244

public DependencyResolutionResult getResult();

245

}

246

```

247

248

**Project Exception Handling Example:**

249

```java

250

import org.apache.maven.project.ProjectBuildingException;

251

import org.apache.maven.project.DependencyResolutionException;

252

import org.apache.maven.project.ProjectBuildingResult;

253

254

public MavenProject handleProjectBuilding(ProjectBuilder projectBuilder,

255

File pomFile,

256

ProjectBuildingRequest request) {

257

try {

258

ProjectBuildingResult result = projectBuilder.build(pomFile, request);

259

260

// Check for non-fatal problems

261

if (!result.getProblems().isEmpty()) {

262

System.out.println("Project built with " + result.getProblems().size() + " problems:");

263

for (ModelProblem problem : result.getProblems()) {

264

System.out.println(" " + problem.getSeverity() + ": " + problem.getMessage() +

265

" (line " + problem.getLineNumber() + ")");

266

}

267

}

268

269

return result.getProject();

270

271

} catch (ProjectBuildingException e) {

272

System.err.println("Failed to build project: " + e.getProjectId());

273

System.err.println("POM file: " + e.getPomFile());

274

275

// Handle batch building results

276

if (e.getResults() != null) {

277

for (ProjectBuildingResult result : e.getResults()) {

278

System.err.println("Project " + result.getProjectId() + ":");

279

for (ModelProblem problem : result.getProblems()) {

280

System.err.println(" " + problem.getSeverity() + ": " + problem.getMessage());

281

}

282

}

283

}

284

285

throw new RuntimeException("Project building failed", e);

286

}

287

}

288

289

public void handleDependencyResolution(ProjectDependenciesResolver resolver,

290

MavenProject project,

291

MavenSession session) {

292

try {

293

DependencyResolutionResult result = resolver.resolve(project,

294

Arrays.asList(Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME), session);

295

296

System.out.println("Resolved " + result.getDependencies().size() + " dependencies");

297

298

} catch (DependencyResolutionException e) {

299

System.err.println("Dependency resolution failed for project: " + project.getName());

300

301

DependencyResolutionResult result = e.getResult();

302

if (result != null) {

303

System.err.println("Resolved: " + result.getDependencies().size());

304

System.err.println("Unresolved: " + result.getUnresolvedDependencies().size());

305

306

// Log unresolved dependencies

307

for (Dependency unresolved : result.getUnresolvedDependencies()) {

308

System.err.println(" Unresolved: " + unresolved.getGroupId() +

309

":" + unresolved.getArtifactId() + ":" + unresolved.getVersion());

310

}

311

312

// Log collection errors

313

for (Exception error : result.getCollectionErrors()) {

314

System.err.println(" Collection error: " + error.getMessage());

315

}

316

}

317

}

318

}

319

```

320

321

## Plugin Exceptions

322

323

### PluginManagerException

324

325

Base exception for plugin management operations.

326

327

```java { .api }

328

public class PluginManagerException extends Exception {

329

/**

330

* Create plugin manager exception.

331

*

332

* @param plugin plugin that caused the error

333

* @param message error message

334

* @param cause underlying cause

335

*/

336

public PluginManagerException(Plugin plugin, String message, Throwable cause);

337

338

/**

339

* Create plugin manager exception with message.

340

*

341

* @param plugin plugin that caused the error

342

* @param message error message

343

*/

344

public PluginManagerException(Plugin plugin, String message);

345

346

/**

347

* Get plugin that caused the exception.

348

*

349

* @return plugin instance

350

*/

351

public Plugin getPlugin();

352

}

353

```

354

355

### PluginNotFoundException

356

357

Exception thrown when a required plugin cannot be found.

358

359

```java { .api }

360

public class PluginNotFoundException extends Exception {

361

/**

362

* Create plugin not found exception.

363

*

364

* @param plugin plugin that was not found

365

*/

366

public PluginNotFoundException(Plugin plugin);

367

368

/**

369

* Create plugin not found exception with message.

370

*

371

* @param plugin plugin that was not found

372

* @param message error message

373

*/

374

public PluginNotFoundException(Plugin plugin, String message);

375

376

/**

377

* Get plugin that was not found.

378

*

379

* @return plugin instance

380

*/

381

public Plugin getPlugin();

382

}

383

```

384

385

### PluginResolutionException

386

387

Exception for plugin resolution failures.

388

389

```java { .api }

390

public class PluginResolutionException extends Exception {

391

/**

392

* Create plugin resolution exception.

393

*

394

* @param plugin plugin that failed to resolve

395

* @param cause underlying cause

396

*/

397

public PluginResolutionException(Plugin plugin, Throwable cause);

398

399

/**

400

* Create plugin resolution exception with message.

401

*

402

* @param plugin plugin that failed to resolve

403

* @param message error message

404

* @param cause underlying cause

405

*/

406

public PluginResolutionException(Plugin plugin, String message, Throwable cause);

407

408

/**

409

* Get plugin that failed to resolve.

410

*

411

* @return plugin instance

412

*/

413

public Plugin getPlugin();

414

}

415

```

416

417

### PluginExecutionException

418

419

Exception for plugin execution failures.

420

421

```java { .api }

422

public class PluginExecutionException extends PluginManagerException {

423

/**

424

* Create plugin execution exception.

425

*

426

* @param project project being built

427

* @param mojoExecution mojo execution that failed

428

* @param message error message

429

* @param cause underlying cause

430

*/

431

public PluginExecutionException(MavenProject project, MojoExecution mojoExecution,

432

String message, Throwable cause);

433

434

/**

435

* Get project where execution failed.

436

*

437

* @return Maven project

438

*/

439

public MavenProject getProject();

440

441

/**

442

* Get mojo execution that failed.

443

*

444

* @return mojo execution

445

*/

446

public MojoExecution getMojoExecution();

447

}

448

```

449

450

**Plugin Exception Handling Example:**

451

```java

452

import org.apache.maven.plugin.PluginNotFoundException;

453

import org.apache.maven.plugin.PluginResolutionException;

454

import org.apache.maven.plugin.PluginExecutionException;

455

import org.apache.maven.plugin.PluginManagerException;

456

457

public void handlePluginOperations(BuildPluginManager pluginManager,

458

MavenSession session,

459

Plugin plugin) {

460

try {

461

// Load plugin

462

PluginDescriptor descriptor = pluginManager.loadPlugin(plugin,

463

session.getCurrentProject().getPluginArtifactRepositories(),

464

session.getRepositorySession());

465

466

// Execute plugin goals

467

for (MojoDescriptor mojo : descriptor.getMojos()) {

468

MojoExecution execution = new MojoExecution(mojo);

469

470

try {

471

pluginManager.executeMojo(session, execution);

472

System.out.println("Executed: " + plugin.getArtifactId() + ":" + mojo.getGoal());

473

474

} catch (PluginExecutionException e) {

475

System.err.println("Plugin execution failed:");

476

System.err.println(" Plugin: " + e.getPlugin().getArtifactId());

477

System.err.println(" Goal: " + e.getMojoExecution().getGoal());

478

System.err.println(" Project: " + e.getProject().getName());

479

System.err.println(" Error: " + e.getMessage());

480

481

// Check for specific failure types

482

if (e.getCause() instanceof MojoFailureException) {

483

System.err.println(" Mojo reported failure: " + e.getCause().getMessage());

484

} else if (e.getCause() instanceof MojoExecutionException) {

485

System.err.println(" Mojo execution error: " + e.getCause().getMessage());

486

}

487

}

488

}

489

490

} catch (PluginNotFoundException e) {

491

System.err.println("Plugin not found: " + e.getPlugin().getGroupId() +

492

":" + e.getPlugin().getArtifactId() + ":" + e.getPlugin().getVersion());

493

System.err.println("Check plugin repositories and coordinates");

494

495

} catch (PluginResolutionException e) {

496

System.err.println("Plugin resolution failed: " + e.getPlugin().getArtifactId());

497

System.err.println("Error: " + e.getMessage());

498

499

// May be caused by dependency conflicts or network issues

500

if (e.getCause() instanceof ArtifactResolutionException) {

501

System.err.println("Artifact resolution problem - check repositories");

502

}

503

504

} catch (PluginManagerException e) {

505

System.err.println("Plugin management error: " + e.getMessage());

506

if (e.getPlugin() != null) {

507

System.err.println("Plugin: " + e.getPlugin().getArtifactId());

508

}

509

}

510

}

511

```

512

513

## Lifecycle Exceptions

514

515

### LifecycleExecutionException

516

517

Exception for lifecycle execution failures.

518

519

```java { .api }

520

public class LifecycleExecutionException extends Exception {

521

/**

522

* Create lifecycle execution exception.

523

*

524

* @param message error message

525

* @param cause underlying cause

526

*/

527

public LifecycleExecutionException(String message, Throwable cause);

528

529

/**

530

* Create lifecycle execution exception with message.

531

*

532

* @param message error message

533

*/

534

public LifecycleExecutionException(String message);

535

536

/**

537

* Create lifecycle execution exception with project context.

538

*

539

* @param project project where execution failed

540

* @param message error message

541

* @param cause underlying cause

542

*/

543

public LifecycleExecutionException(MavenProject project, String message, Throwable cause);

544

545

/**

546

* Get project where lifecycle execution failed.

547

*

548

* @return Maven project or null

549

*/

550

public MavenProject getProject();

551

}

552

```

553

554

### LifecycleNotFoundException

555

556

Exception when a requested lifecycle is not found.

557

558

```java { .api }

559

public class LifecycleNotFoundException extends Exception {

560

/**

561

* Create lifecycle not found exception.

562

*

563

* @param lifecycleId lifecycle identifier that was not found

564

*/

565

public LifecycleNotFoundException(String lifecycleId);

566

567

/**

568

* Create lifecycle not found exception with message.

569

*

570

* @param lifecycleId lifecycle identifier

571

* @param message error message

572

*/

573

public LifecycleNotFoundException(String lifecycleId, String message);

574

575

/**

576

* Get lifecycle identifier that was not found.

577

*

578

* @return lifecycle ID

579

*/

580

public String getLifecycleId();

581

}

582

```

583

584

**Lifecycle Exception Handling Example:**

585

```java

586

import org.apache.maven.lifecycle.LifecycleExecutionException;

587

import org.apache.maven.lifecycle.LifecycleNotFoundException;

588

589

public void handleLifecycleExecution(LifecycleExecutor lifecycleExecutor,

590

MavenSession session,

591

String... goals) {

592

try {

593

// Calculate execution plan

594

MavenExecutionPlan plan = lifecycleExecutor.calculateExecutionPlan(session, goals);

595

596

// Execute lifecycle

597

lifecycleExecutor.execute(session);

598

599

System.out.println("Lifecycle execution completed successfully");

600

601

} catch (LifecycleExecutionException e) {

602

System.err.println("Lifecycle execution failed: " + e.getMessage());

603

604

if (e.getProject() != null) {

605

System.err.println("Failed project: " + e.getProject().getName());

606

}

607

608

// Analyze failure cause

609

Throwable cause = e.getCause();

610

if (cause instanceof PluginExecutionException) {

611

PluginExecutionException pluginError = (PluginExecutionException) cause;

612

System.err.println("Plugin failure: " + pluginError.getPlugin().getArtifactId() +

613

":" + pluginError.getMojoExecution().getGoal());

614

} else if (cause instanceof MojoFailureException) {

615

System.err.println("Mojo reported failure: " + cause.getMessage());

616

}

617

618

} catch (LifecycleNotFoundException e) {

619

System.err.println("Unknown lifecycle: " + e.getLifecycleId());

620

System.err.println("Available lifecycles: default, clean, site");

621

622

} catch (PluginNotFoundException e) {

623

System.err.println("Required plugin not found: " + e.getPlugin().getArtifactId());

624

System.err.println("Add plugin to project POM or check plugin repositories");

625

}

626

}

627

```

628

629

## Repository Exceptions

630

631

### ArtifactTransferFailedException

632

633

Exception for artifact transfer failures.

634

635

```java { .api }

636

public class ArtifactTransferFailedException extends Exception {

637

/**

638

* Create artifact transfer failed exception.

639

*

640

* @param artifact artifact that failed to transfer

641

* @param repository repository involved in transfer

642

* @param message error message

643

*/

644

public ArtifactTransferFailedException(Artifact artifact, ArtifactRepository repository, String message);

645

646

/**

647

* Create artifact transfer failed exception with cause.

648

*

649

* @param artifact artifact that failed to transfer

650

* @param repository repository involved in transfer

651

* @param message error message

652

* @param cause underlying cause

653

*/

654

public ArtifactTransferFailedException(Artifact artifact, ArtifactRepository repository,

655

String message, Throwable cause);

656

657

/**

658

* Get artifact that failed to transfer.

659

*

660

* @return artifact instance

661

*/

662

public Artifact getArtifact();

663

664

/**

665

* Get repository involved in transfer.

666

*

667

* @return artifact repository

668

*/

669

public ArtifactRepository getRepository();

670

}

671

```

672

673

### ArtifactDoesNotExistException

674

675

Exception when a requested artifact does not exist.

676

677

```java { .api }

678

public class ArtifactDoesNotExistException extends Exception {

679

/**

680

* Create artifact does not exist exception.

681

*

682

* @param artifact artifact that does not exist

683

* @param repository repository that was searched

684

*/

685

public ArtifactDoesNotExistException(Artifact artifact, ArtifactRepository repository);

686

687

/**

688

* Create artifact does not exist exception with message.

689

*

690

* @param artifact artifact that does not exist

691

* @param repository repository that was searched

692

* @param message error message

693

*/

694

public ArtifactDoesNotExistException(Artifact artifact, ArtifactRepository repository, String message);

695

696

/**

697

* Get artifact that does not exist.

698

*

699

* @return artifact instance

700

*/

701

public Artifact getArtifact();

702

703

/**

704

* Get repository that was searched.

705

*

706

* @return artifact repository

707

*/

708

public ArtifactRepository getRepository();

709

}

710

```

711

712

**Repository Exception Handling Example:**

713

```java

714

import org.apache.maven.repository.ArtifactTransferFailedException;

715

import org.apache.maven.repository.ArtifactDoesNotExistException;

716

717

public void handleRepositoryOperations(RepositorySystem repositorySystem,

718

RepositorySystemSession session,

719

List<RemoteRepository> repositories) {

720

Artifact artifact = new DefaultArtifact("com.example", "missing-artifact", "jar", "1.0.0");

721

722

try {

723

ArtifactRequest request = new ArtifactRequest();

724

request.setArtifact(artifact);

725

request.setRepositories(repositories);

726

727

ArtifactResult result = repositorySystem.resolve(session, request);

728

729

if (result.isResolved()) {

730

System.out.println("Artifact resolved: " + result.getArtifact().getFile());

731

}

732

733

} catch (ArtifactResolutionException e) {

734

System.err.println("Artifact resolution failed: " + e.getMessage());

735

736

// Check for specific causes

737

for (Exception cause : e.getResult().getExceptions()) {

738

if (cause instanceof ArtifactDoesNotExistException) {

739

ArtifactDoesNotExistException notFound = (ArtifactDoesNotExistException) cause;

740

System.err.println("Artifact not found in repository: " +

741

notFound.getRepository().getId());

742

743

} else if (cause instanceof ArtifactTransferFailedException) {

744

ArtifactTransferFailedException transferFailed = (ArtifactTransferFailedException) cause;

745

System.err.println("Transfer failed from repository: " +

746

transferFailed.getRepository().getId());

747

System.err.println("Transfer error: " + transferFailed.getMessage());

748

749

// Check for network issues

750

if (transferFailed.getCause() instanceof ConnectException) {

751

System.err.println("Network connection failed - check repository URL and connectivity");

752

} else if (transferFailed.getCause() instanceof UnknownHostException) {

753

System.err.println("Cannot resolve repository host - check DNS and repository URL");

754

}

755

}

756

}

757

758

// Suggest fallback strategies

759

System.err.println("Suggestions:");

760

System.err.println("- Check artifact coordinates");

761

System.err.println("- Verify repository URLs and accessibility");

762

System.err.println("- Check network connectivity");

763

System.err.println("- Add additional repositories if needed");

764

}

765

}

766

```

767

768

## Exception Handling Best Practices

769

770

### Comprehensive Error Handling Strategy

771

772

```java

773

public class MavenErrorHandler {

774

775

public void handleMavenBuild(Maven maven, MavenExecutionRequest request) {

776

try {

777

MavenExecutionResult result = maven.execute(request);

778

779

if (result.hasExceptions()) {

780

categorizeAndHandleExceptions(result.getExceptions());

781

} else {

782

logSuccessfulBuild(result);

783

}

784

785

} catch (Exception e) {

786

handleUnexpectedException(e);

787

}

788

}

789

790

private void categorizeAndHandleExceptions(List<Throwable> exceptions) {

791

Map<Class<?>, List<Throwable>> categorized = exceptions.stream()

792

.collect(Collectors.groupingBy(Throwable::getClass));

793

794

// Handle each exception category

795

categorized.forEach(this::handleExceptionCategory);

796

797

// Generate summary report

798

generateErrorReport(exceptions);

799

}

800

801

private void handleExceptionCategory(Class<?> exceptionType, List<Throwable> exceptions) {

802

if (ProjectBuildingException.class.isAssignableFrom(exceptionType)) {

803

handleProjectBuildingExceptions(exceptions);

804

} else if (PluginExecutionException.class.isAssignableFrom(exceptionType)) {

805

handlePluginExecutionExceptions(exceptions);

806

} else if (DependencyResolutionException.class.isAssignableFrom(exceptionType)) {

807

handleDependencyResolutionExceptions(exceptions);

808

} else if (LifecycleExecutionException.class.isAssignableFrom(exceptionType)) {

809

handleLifecycleExecutionExceptions(exceptions);

810

} else {

811

handleGenericExceptions(exceptions);

812

}

813

}

814

815

private void handleProjectBuildingExceptions(List<Throwable> exceptions) {

816

System.err.println("=== PROJECT BUILDING ERRORS ===");

817

818

for (Throwable exception : exceptions) {

819

ProjectBuildingException pbe = (ProjectBuildingException) exception;

820

System.err.println("Project: " + pbe.getProjectId());

821

System.err.println("POM: " + pbe.getPomFile());

822

823

if (pbe.getResults() != null) {

824

for (ProjectBuildingResult result : pbe.getResults()) {

825

logModelProblems(result.getProblems());

826

}

827

}

828

}

829

}

830

831

private void logModelProblems(List<ModelProblem> problems) {

832

for (ModelProblem problem : problems) {

833

String severity = problem.getSeverity().toString();

834

System.err.println(" " + severity + ": " + problem.getMessage());

835

836

if (problem.getLineNumber() > 0) {

837

System.err.println(" at line " + problem.getLineNumber());

838

}

839

}

840

}

841

842

private void generateErrorReport(List<Throwable> exceptions) {

843

System.err.println("\n=== BUILD ERROR SUMMARY ===");

844

System.err.println("Total errors: " + exceptions.size());

845

846

Map<String, Long> errorCounts = exceptions.stream()

847

.collect(Collectors.groupingBy(

848

e -> e.getClass().getSimpleName(),

849

Collectors.counting()));

850

851

errorCounts.forEach((type, count) ->

852

System.err.println(type + ": " + count));

853

}

854

}

855

```

856

857

## Types

858

859

```java { .api }

860

public interface ModelProblem {

861

enum Severity {

862

FATAL, ERROR, WARNING

863

}

864

865

String getMessage();

866

Severity getSeverity();

867

int getLineNumber();

868

int getColumnNumber();

869

String getSource();

870

Exception getException();

871

}

872

873

public class MojoFailureException extends AbstractMojoExecutionException {

874

public MojoFailureException(String message);

875

public MojoFailureException(String message, Throwable cause);

876

public MojoFailureException(Object source, String shortMessage, String longMessage);

877

}

878

879

public class MojoExecutionException extends AbstractMojoExecutionException {

880

public MojoExecutionException(String message);

881

public MojoExecutionException(String message, Throwable cause);

882

public MojoExecutionException(Object source, String shortMessage, String longMessage);

883

}

884

885

public class PluginConfigurationException extends Exception {

886

public PluginConfigurationException(ComponentDescriptor componentDescriptor, String message);

887

public PluginConfigurationException(ComponentDescriptor componentDescriptor, String message, Throwable cause);

888

}

889

890

public class PluginContainerException extends Exception {

891

public PluginContainerException(String message);

892

public PluginContainerException(String message, Throwable cause);

893

}

894

895

public class ArtifactResolutionException extends Exception {

896

public ArtifactResolutionException(List<ArtifactResult> results);

897

public ArtifactResolutionException(List<ArtifactResult> results, String message, Throwable cause);

898

899

public List<ArtifactResult> getResults();

900

}

901

902

public class DependencyCollectionException extends Exception {

903

public DependencyCollectionException(CollectResult result);

904

public DependencyCollectionException(CollectResult result, String message);

905

906

public CollectResult getResult();

907

}

908

```