• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mermaid-js / mermaid / 4567499147

pending completion
4567499147

Pull #4258

github

GitHub
Merge 7739302ee into e4a2c74b1
Pull Request #4258: fix(#4256): Keep error diagram on screen

1610 of 1963 branches covered (82.02%)

Branch coverage included in aggregate %.

13 of 13 new or added lines in 4 files covered. (100.0%)

15946 of 32888 relevant lines covered (48.49%)

404.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.0
/packages/mermaid/src/diagrams/error/errorRenderer.ts
1
/** Created by knut on 14-12-11. */
1✔
2
// @ts-ignore TODO: Investigate D3 issue
1✔
3
import { select } from 'd3';
1✔
4
import { log } from '../../logger';
1✔
5
import { getErrorMessage } from '../../utils';
1✔
6

1✔
7
/**
1✔
8
 * Merges the value of `conf` with the passed `cnf`
1✔
9
 *
1✔
10
 * @param cnf - Config to merge
1✔
11
 */
1✔
12
export const setConf = function () {
1✔
13
  // no-op
×
14
};
×
15

1✔
16
/**
1✔
17
 * Draws a an info picture in the tag with id: id based on the graph definition in text.
1✔
18
 *
1✔
19
 * @param _text - Mermaid graph definition.
1✔
20
 * @param id - The text for the error
1✔
21
 * @param mermaidVersion - The version
1✔
22
 */
1✔
23
export const draw = (_text: string, id: string, mermaidVersion: string) => {
1✔
24
  try {
×
25
    log.debug('Renering svg for syntax error\n');
×
26

×
27
    const svg = select('#' + id);
×
28

×
29
    const g = svg.append('g');
×
30

×
31
    g.append('path')
×
32
      .attr('class', 'error-icon')
×
33
      .attr(
×
34
        'd',
×
35
        'm411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z'
×
36
      );
×
37

×
38
    g.append('path')
×
39
      .attr('class', 'error-icon')
×
40
      .attr(
×
41
        'd',
×
42
        'm459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z'
×
43
      );
×
44

×
45
    g.append('path')
×
46
      .attr('class', 'error-icon')
×
47
      .attr(
×
48
        'd',
×
49
        'm340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z'
×
50
      );
×
51

×
52
    g.append('path')
×
53
      .attr('class', 'error-icon')
×
54
      .attr(
×
55
        'd',
×
56
        'm400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z'
×
57
      );
×
58

×
59
    g.append('path')
×
60
      .attr('class', 'error-icon')
×
61
      .attr(
×
62
        'd',
×
63
        'm496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z'
×
64
      );
×
65

×
66
    g.append('path')
×
67
      .attr('class', 'error-icon')
×
68
      .attr(
×
69
        'd',
×
70
        'm436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z'
×
71
      );
×
72

×
73
    g.append('text') // text label for the x axis
×
74
      .attr('class', 'error-text')
×
75
      .attr('x', 1440)
×
76
      .attr('y', 250)
×
77
      .attr('font-size', '150px')
×
78
      .style('text-anchor', 'middle')
×
79
      .text('Syntax error in text');
×
80
    g.append('text') // text label for the x axis
×
81
      .attr('class', 'error-text')
×
82
      .attr('x', 1250)
×
83
      .attr('y', 400)
×
84
      .attr('font-size', '100px')
×
85
      .style('text-anchor', 'middle')
×
86
      .text('mermaid version ' + mermaidVersion);
×
87

×
88
    svg.attr('height', 100);
×
89
    svg.attr('width', 500);
×
90
    svg.attr('viewBox', '768 0 912 512');
×
91
  } catch (e) {
×
92
    log.error('Error while rendering info diagram');
×
93
    log.error(getErrorMessage(e));
×
94
  }
×
95
};
×
96

1✔
97
export default {
1✔
98
  setConf,
1✔
99
  draw,
1✔
100
};
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc