Luracast / Restler

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API
http://luracast.com/products/restler/
GNU Lesser General Public License v2.1
1.36k stars 315 forks source link

How custom exception for FHIR #681

Open ander-chan opened 2 years ago

ander-chan commented 2 years ago

Regards!. In the FHIR is a standard the output is represented by "OperationOutcome's" and the errors, the same eg:.

{
    "resourceType": "OperationOutcome",
    "meta": {
        "profile": ["https://fhir.nhs.uk/STU3/StructureDefinition/GPConnect-OperationOutcome-1"]
    },
    "issue": [{
        "severity": "error",
        "code": "not-found",
        "details": {
            "coding": [{
                "system": "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1",
                "code": "PATIENT_NOT_FOUND",
                "display": "Patient not found"
            }]
        }
    }]
}
<?xml version="1.0" encoding="UTF-8"?><OperationOutcome xmlns="http://hl7.org/fhir">
  <id value="searchfail"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
      <p>The &quot;name&quot; parameter has the modifier &quot;exact&quot; which is not supported by this server</p>
    </div>
  </text>
  <issue>
    <severity value="fatal"/>
    <code value="code-invalid"/>
    <details>
      <text value="The &quot;name&quot; parameter has the modifier &quot;exact&quot; which is not supported by this server"/>    
    </details> 
    <location value="http.name:exact"/>    
  </issue>
</OperationOutcome>

I'm thinking extends RestExeption... How custom the actual output exception?

{
  "error": {
    "code": 400,
    "message": "Bad Request: `login` is required."
  }
}