Commit 0ac638cb authored by Paul Asmuth's avatar Paul Asmuth
Browse files

improve error handling

parent c8eb32ee
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ bool AxisDefinition::hasTitle() const {
  return title_.length() > 0;
}

void renderAxisVertical(
Status renderAxisVertical(
    const AxisDefinition& axis_config,
    double x,
    double y0,
@@ -98,16 +98,15 @@ void renderAxisVertical(
    TextStyle style;
    style.halign = TextHAlign::LEFT;
    style.valign = TextVAlign::TOP;
    drawText(
        label_text,
        style,
        x,
        y,
        target);
    if (auto rc = drawText(label_text, style, x, y, target); rc != OK) {
      return rc;
    }
  }

void renderAxisHorizontal(
  return OK;
}

Status renderAxisHorizontal(
    const AxisDefinition& axis_config,
    double y,
    double x0,
@@ -137,6 +136,8 @@ void renderAxisHorizontal(
    StrokeStyle style;
    strokeLine(target, x, y, x, y + kTickLength * label_placement, style);
  }

  return OK;
}

}
+2 −2
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ struct AxisDefinitions {
/**
 * Render a vertical axis
 */
void renderAxisVertical(
Status renderAxisVertical(
    const AxisDefinition& axis_config,
    double x,
    double y0,
@@ -144,7 +144,7 @@ void renderAxisVertical(
/**
 * Render a horizontal axis
 */
void renderAxisHorizontal(
Status renderAxisHorizontal(
    const AxisDefinition& axis_config,
    double y,
    double x0,
+4 −4
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ int main(int argc, char** argv) {
    axis.addLabel(0.6, "d");
    axis.addLabel(0.8, "e");
    axis.addLabel(1.0, "f");
    renderAxisVertical(axis, padding, padding, target.height - padding, &target);
    CHECK_RC(renderAxisVertical(axis, padding, padding, target.height - padding, &target));
  }

  // draw right axis
@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
    axis.addLabel(0.6, "d");
    axis.addLabel(0.8, "e");
    axis.addLabel(1.0, "f");
    renderAxisVertical(axis, target.width - padding, padding, target.height - padding, &target);
    CHECK_RC(renderAxisVertical(axis, target.width - padding, padding, target.height - padding, &target));
  }

  // draw top axis
@@ -73,7 +73,7 @@ int main(int argc, char** argv) {
    axis.addLabel(0.6, "d");
    axis.addLabel(0.8, "e");
    axis.addLabel(1.0, "f");
    renderAxisHorizontal(axis, padding, padding, target.width - padding, &target);
    CHECK_RC(renderAxisHorizontal(axis, padding, padding, target.width - padding, &target));
  }

  // draw bottom axis
@@ -92,7 +92,7 @@ int main(int argc, char** argv) {
    axis.addLabel(0.6, "d");
    axis.addLabel(0.8, "e");
    axis.addLabel(1.0, "f");
    renderAxisHorizontal(axis, target.height - padding, padding, target.width - padding, &target);
    CHECK_RC(renderAxisHorizontal(axis, target.height - padding, padding, target.width - padding, &target));
  }

  CHECK_RC(target.writeToFile(std::string(argv[0]) + ".png"));