|
1 |
| package com.agical.rmock.core.exception; |
|
2 |
| |
|
3 |
| import java.util.Stack; |
|
4 |
| |
|
5 |
| import com.agical.rmock.core.Section; |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| public class UnclosedSectionException extends RuntimeException { |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| private static final long serialVersionUID = 1L; |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
1
| public UnclosedSectionException(Stack sectionStack) {
|
|
24 |
1
| super(createMessage(sectionStack));
|
|
25 |
| } |
|
26 |
| |
|
27 |
1
| static String createMessage(Stack sectionStack) {
|
|
28 |
1
| StringBuffer stringBuffer = new StringBuffer( "\nThe following sections must be closed: " );
|
|
29 |
1
| while( sectionStack.size() > 1 ) {
|
|
30 |
1
| Section section = (Section) sectionStack.pop();
|
|
31 |
1
| stringBuffer.append( "\n - " ).append( section.getType() ).append( ":" ).append( section.getDescription() );
|
|
32 |
| } |
|
33 |
1
| return stringBuffer.toString();
|
|
34 |
| } |
|
35 |
| } |