Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions xyz-util/src/main/resources/sql/Exception.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2024 HERE Europe B.V.
* Copyright (C) 2017-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,10 +22,22 @@ class Exception extends Error {
context;
detail;
hint;
cause;

constructor(message) {
constructor(message, cause = null) {
super(message);
this.withDetail(this.constructor.name + ": ");
this.cause = cause;

//Build the context information
this.context = this.stack;

if (cause instanceof Exception)
this.context += "\nCaused by: " + cause.context;
else if (cause instanceof Error)
this.context += "\nCaused by: " + cause.stack;
else
this.context += "\nCaused by: " + cause;
}

withCode(code) {
Expand All @@ -40,11 +52,6 @@ class Exception extends Error {
return this;
}

withContext(context) {
this.context = context;
return this;
}

withDetail(detail) {
this.detail = detail;
return this;
Expand All @@ -57,43 +64,43 @@ class Exception extends Error {
}

class XyzException extends Exception {
constructor(message) {
super(message);
constructor(message, cause = null) {
super(message, cause);
this.withCode("XYZ50");
}
}

class VersionConflictError extends XyzException {
constructor(message) {
super(message);
constructor(message, cause = null) {
super(message, cause);
this.withCode("XYZ49");
}
}

class MergeConflictError extends VersionConflictError {
constructor(message) {
super(message);
constructor(message, cause = null) {
super(message, cause);
this.withCode("XYZ48");
}
}

class IllegalArgumentException extends XyzException {
constructor(message) {
super(message);
constructor(message, cause = null) {
super(message, cause);
this.withCode("XYZ40");
}
}

class FeatureExistsException extends XyzException {
constructor(message) {
super(message);
constructor(message, cause = null) {
super(message, cause);
this.withCode("XYZ20");
}
}

class FeatureNotExistsException extends XyzException {
constructor(message) {
super(message);
constructor(message, cause = null) {
super(message, cause);
this.withCode("XYZ44");
}
}
Expand Down
4 changes: 2 additions & 2 deletions xyz-util/src/main/resources/sql/FeatureWriter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2024 HERE Europe B.V.
* Copyright (C) 2017-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -342,7 +342,7 @@ class FeatureWriter {
if (this.onExists == "ERROR")
this._throwFeatureExistsError();
else
throw new XyzException("Unexpected conflict while trying to perform write operation.").withDetail(e.detail).withHint(e.hint);
throw new XyzException("Unexpected conflict while trying to perform write operation.", e).withDetail(e.detail).withHint(e.hint);
}

this.debugBox(e.stack);
Expand Down
4 changes: 2 additions & 2 deletions xyz-util/src/main/resources/sql/feature_writer.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2024 HERE Europe B.V.
* Copyright (C) 2017-2025 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,7 +72,7 @@ $BODY$
}
catch (error) {
if (!error.code)
throw new Error("Unexpected error in feature_writer: " + error.message);
throw new Exception("Unexpected error in feature_writer: " + error.message, error);
else
throw error;
}
Expand Down
Loading